zebra/zebrad/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
..
bin/zebrad Standardise clippy lints and require docs (#2238) 2021-06-04 08:48:40 +10:00
commands Sneak chain_tip_change into mempool (#2785) 2021-09-21 17:06:52 +00:00
components 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
application.rs Add the database format to the panic metadata (#2249) 2021-06-04 14:42:15 +10:00
commands.rs Log configured network in every log message (#1568) 2021-01-12 07:46:56 +10:00
components.rs Move transaction download and verify stream into the mempool service (#2741) 2021-09-13 16:28:07 -04:00
config.rs Add journald support through tracing-journald (#2034) 2021-04-22 09:31:06 +10:00
lib.rs Standardise clippy lints and require docs (#2238) 2021-06-04 08:48:40 +10:00
prelude.rs Fix a deadlock in TokioComponent. 2020-01-15 12:06:31 -08:00
sentry.rs Standardise clippy lints and require docs (#2238) 2021-06-04 08:48:40 +10:00