Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(block-producer): remove Store traits #571

Merged
merged 4 commits into from
Dec 10, 2024

Conversation

Mirko-von-Leipzig
Copy link
Contributor

@Mirko-von-Leipzig Mirko-von-Leipzig commented Dec 9, 2024

This PR removes the block producer's Store and ApplyBlock traits.

Instead the methods are moved directly into the DefaultStore struct, which has also been renamed to a more appropriate StoreClient.

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.

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you! I left just one small comment inline.

Also, should we create an issue for a bigger refactoring of the tests?

crates/block-producer/src/store/mod.rs Show resolved Hide resolved
@Mirko-von-Leipzig
Copy link
Contributor Author

Also, should we create an issue for a bigger refactoring of the tests?

#573

@Mirko-von-Leipzig Mirko-von-Leipzig merged commit 2e3fa34 into next Dec 10, 2024
8 checks passed
@Mirko-von-Leipzig Mirko-von-Leipzig deleted the mirko/refactor/remove-store-trait branch December 10, 2024 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants