-
Notifications
You must be signed in to change notification settings - Fork 296
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
blockchain: Add UtxoCache Initialize tests. #2599
Merged
Merged
Conversation
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
davecgh
added
the
test coverage
Discussion and pull requests for improving test coverage.
label
Feb 19, 2021
rstaudt2
force-pushed
the
utxo-cache-init-tests
branch
from
February 23, 2021 02:13
4ef14cc
to
eb8048a
Compare
dnldd
reviewed
Feb 26, 2021
davecgh
requested changes
Feb 27, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great to see more tests around this to ensure it's handling the edge cases properly.
I noticed a few minor things that I've noted inline.
This changes the InitUtxoCache method on the BlockChain type to a Initialize method on the UtxoCache type instead. This simplifies providing alternative implementations for testing since the Initialize method deals with internal fields of the UtxoCache type.
This adds a UtxoCacher interface so that alternative utxo cache implementations can be provided. In particular, this will be used to provide a mock implementation for testing in order to more easily simulate various scenarios. In addition to introducing the UtxoCacher interface, this updates BlockChain and UtxoViewpoint to use the interface rather than the concrete type.
This adds tests for the UtxoCache Initialize method. These tests include recovery scenarios that are particularly hard to simulate to ensure that those code paths are not broken in the future. In order to test recovery scenarios, this introduces a test utxo cache that allows for toggling flushing on and off. Additionally, this adds an ExpectUtxoSetState method to chaingenHarness that allows for easily validating the last flushed block for the utxo set.
rstaudt2
force-pushed
the
utxo-cache-init-tests
branch
from
February 27, 2021 23:04
eb8048a
to
29e5b9b
Compare
davecgh
approved these changes
Feb 28, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 is rebased on #2591.
This adds additional tests around utxo cache initialization to ensure that it recovers in various scenarios that are hard to simulate or hit with manual testing. The changes are as follows: