refactor(block-producer): remove Store traits #571
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR removes the block producer's
Store
andApplyBlock
traits.Instead the methods are moved directly into the
DefaultStore
struct, which has also been renamed to a more appropriateStoreClient
.The traits were required to facilitate mocking as part of tests. Most of these usages were removed as part of the mempool work, which allowed these traits to largely just disappear.
There are still some remnants lurking (
MockStoreSuccess
et al), but these require larger refactors to the underlying tests.In general, we should avoid mocks where possible as its very easy for things to desync with reality. And indeed some of the above tests aren't actually testing the unit-under-test but rather the test setup code. Ideally we would have an actual in-memory store running for each test however this is quite a lot of work. A potentially simpler option is to implement the gRPC server for tests (skipping the database).
Closes #196 and closes #565.