-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a helper
MockService
type to help with writing tests that us…
…e 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 <[email protected]>
- Loading branch information
1 parent
061ad55
commit b714b2b
Showing
4 changed files
with
798 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.