Zebra/zebra-test/src
Janito Vaqueiro Ferreira Filho b714b2b3b6
Create a helper `MockService` type to help with writing tests that use mock `tower::Service`s (#2748)
* Implement initial service mocking helpers

Adds a [`MockService`] type, which can be configured and built for usage
in unit tests or proptests. The mocked service can then be used to
intercept requests and respond indivdiually to them.

* Use `MockService in the `mempool::Crawler` test

Refactor it to remove the helper mock function, and use the new
`MockService` helper type.

* Use `MockService` in `CandidateSet` test vectors

Refactor to remove the manual mocking of the peer set service.

* Panic if a response is not sent by `MockService`

Change the current semantics to require all `MockService` usages to
respond to every intercepted request.

A `must_use` attribute was added to the `ResponseSender` so that the
compiler can warn when this doesn't happen.

* Allow generic error types in `MockService`

Replace the hard-coded `BoxError` as the `Service`'s error type with a
generic type parameter. This allows mocking services in locations that
require specific error types.

* Add a `ResponseSender::request` getter

Allow inspecting the request again before responding, and using
information from the request in the response.

Co-authored-by: Conrado Gouvea <conrado@zfnd.org>
2021-09-21 17:44:59 +00:00
..
vectors Add final sapling root test vectors (#2243) 2021-06-04 10:31:47 -03:00
command.rs Improve docs and panic messages for zebra_test::command (#2406) 2021-06-28 10:35:56 -03:00
lib.rs Create a helper `MockService` type to help with writing tests that use mock `tower::Service`s (#2748) 2021-09-21 17:44:59 +00:00
mock_service.rs Create a helper `MockService` type to help with writing tests that use mock `tower::Service`s (#2748) 2021-09-21 17:44:59 +00:00
net.rs Release Blocker? Disable IPv6 tests when $ZEBRA_SKIP_IPV6_TESTS is set (#2405) 2021-06-29 11:20:32 +10:00
prelude.rs Standardise clippy lints and require docs (#2238) 2021-06-04 08:48:40 +10:00
transcript.rs Standardise clippy lints and require docs (#2238) 2021-06-04 08:48:40 +10:00
vectors.rs Standardise clippy lints and require docs (#2238) 2021-06-04 08:48:40 +10:00
zip0143.rs Always compute sighash with librustzcash (#2469) 2021-07-09 09:55:08 +10:00
zip0243.rs Fix bug in sighash for coinbase transactions (#2459) 2021-07-08 16:05:40 -03:00
zip0244.rs Add ZIP-244 signature hash support (#2165) 2021-07-07 08:27:10 +10:00