Zebra/zebra-network/src/peer_set
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
..
candidate_set 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
initialize Refactor BestTipHeight into a generic ChainTip sender and receiver (#2676) 2021-08-27 11:34:33 +10:00
candidate_set.rs Security: Zebra should stop gossiping unreachable addresses to other nodes, Action: re-deploy all nodes (#2392) 2021-06-29 05:12:27 +00:00
initialize.rs Add a `ChainTipChange` type to `await` chain tip changes (#2715) 2021-09-01 22:31:16 +00:00
inventory_registry.rs Remove a redundant pattern match 2020-12-13 22:10:05 -05:00
set.rs Support witnessed transaction IDs in zebra-network requests and responses (#2638) 2021-08-18 22:55:24 +00:00
unready_service.rs Clarify a comment 2021-04-07 18:56:38 +10:00