pub async fn expect_request(
        &mut self,
        expected: Request,
    ) -> Result<ResponseSender<Request, Response, Error>, TestCaseError>
    where
        Request: PartialEq + Debug,
    {
        let response_sender = self.next_request().await?;

        prop_assert_eq!(&response_sender.request, &expected);

        Ok(response_sender)
    }
/// Expect a specific request to be received.
///
/// The expected request should be the next one in the internal queue, or if the queue is
/// empty, it should be received in at most the max delay time configured by
/// [`MockServiceBuilder::with_max_request_delay`].
///
/// If the received request matches the expected request, a [`ResponseSender`] is returned
/// which can be used to inspect the request and respond to it. If no response is sent, the
/// sender of the requests receives an error.
///
/// If no request is received or if a request is received that's not equal to the expected
/// request, this method returns an error generated by a [`proptest`] assertion.
///
/// # Example
///
/// ```
/// # use proptest::prelude::*;
/// # use tower::ServiceExt;
/// #
/// # use zebra_test::mock_service::MockService;
/// #
/// # let reactor = tokio::runtime::Builder::new_current_thread()
/// #     .enable_all()
/// #     .build()
/// #     .expect("Failed to build Tokio runtime");
/// #
/// # reactor.block_on(async {
/// #     let test_code = || async {
/// #         let mut mock_service: MockService<_, _, _> =
/// #             MockService::build().for_prop_tests();
/// #         let mut service = mock_service.clone();
/// #
/// let call = tokio::spawn(mock_service.clone().oneshot("request"));
///
/// // NOTE: The try operator `?` is required for errors to be handled by proptest.
/// mock_service
///     .expect_request("request").await?
///     .respond("response");
///
/// prop_assert!(matches!(call.await, Ok(Ok("response"))));
/// #
/// #         Ok::<(), TestCaseError>(())
/// #     };
/// #     test_code().await
/// # }).unwrap();
/// ```
Expect a specific request to be received.
The expected request should be the next one in the internal queue, or if the queue is
empty, it should be received in at most the max delay time configured by
[`MockServiceBuilder::with_max_request_delay`].

If the received request matches the expected request, a [`ResponseSender`] is returned
which can be used to inspect the request and respond to it. If no response is sent, the
sender of the requests receives an error.

If no request is received or if a request is received that's not equal to the expected
request, this method returns an error generated by a [`proptest`] assertion.
Expect a specific request to be received . The expected request should be the next one in the internal queue or if the queue is empty it should be received in at most the max delay time configured by [ ` MockServiceBuilder :: with_max_request_delay ` ] . If the received request matches the expected request a [ ` ResponseSender ` ] is returned which can be used to inspect the request and respond to it . If no response is sent the sender of the requests receives an error . If no request is received or if a request is received that ' s not equal to the expected request this method returns an error generated by a [ ` proptest ` ] assertion .
pub async fn expect_request(
        &mut self,
        expected: Request,
    ) -> Result<ResponseSender<Request, Response, Error>, TestCaseError>
    where
        Request: PartialEq + Debug,
    {
        let response_sender = self.next_request().await?;
        prop_assert_eq!(&response_sender.request, &expected);
        Ok(response_sender)
    }
pub async fn expect_request ( & mut self , expected : Request , ) -> Result < ResponseSender < Request , Response , Error > , TestCaseError > where Request : PartialEq + Debug , { let response_sender = self . next_request ( ) . await ? ; prop_assert_eq ! ( response_sender request expected ) ; Ok ( response_sender ) }
Expect a specific request to be received.
Expect a specific request to be received .
&mut self
expected
Request
example
None
use proptest::prelude::*;
None
use tower::serviceext;
None
use zebra_test::mock_service::mockservice;
None
let reactor = tokio::runtime::builder::new_current_thread()
None
.enable_all()
None
.build()
None
.expect("failed to build tokio runtime");
None
reactor.block_on(async {
None
let test_code = || async {
None
let mut mock_service: mockservice<_, _, _> 
None
mockservice::build().for_prop_tests();
None
let mut service = mock_service.clone();
let call = tokio::spawn(mock_service.clone().oneshot("request")).

The try operator `?` is required for errors to be handled by proptest.
mock_service
.expect_request("request").await.
.respond("response").

prop_assert!(matches!(call.await, Ok(Ok("response")))).
let call = tokio :: spawn ( mock_service . clone () . oneshot ( " request " )) . The try operator ` ? ` is required for errors to be handled by proptest . mock_service . expect_request ( " request " ) . await . . respond ( " response " ) . prop_assert! ( matches! ( call . await Ok ( Ok ( " response " )))) .
ok::<(), testcaseerror>(())
None
};
None
test_code().await
None
}).unwrap();
None