[test] Add CCoinsViewCache Access/Modify/Write tests#9308
Merged
laanwj merged 1 commit intobitcoin:masterfrom Dec 21, 2016
Merged
[test] Add CCoinsViewCache Access/Modify/Write tests#9308laanwj merged 1 commit intobitcoin:masterfrom
laanwj merged 1 commit intobitcoin:masterfrom
Conversation
Add more comprehensive unit tests for CCoinsViewCache. Right now it is hard to refactor caching code or fix bugs in the caching logic because you have to try to mentally enumerate all the different states the cache might be in to make sure a change doesn't cause unintended consequences. The new tests explicitly enumerate relevant cache states, documenting and verifying the behavior in each state, so it will be safer and easier to make changes to the caching code in the future.
ada92a8 to
03ffa4c
Compare
Member
|
utACK 03ffa4c, thanks for adding tests for this important system |
Member
|
Concept ACK 03ffa4c |
morcos
reviewed
Dec 19, 2016
src/test/coins_tests.cpp
Outdated
|
|
||
| void CheckModifyNewCoins(CAmount cache_value, CAmount modify_value, CAmount expected_value, char cache_flags, char expected_flags, bool coinbase) | ||
| { | ||
| SingleEntryCacheTest test(ABSENT, cache_value, cache_flags); |
Contributor
There was a problem hiding this comment.
Maybe loop over possibilities for base values
morcos
reviewed
Dec 19, 2016
| BOOST_CHECK_EQUAL(result_flags, expected_flags); | ||
| } | ||
|
|
||
| BOOST_AUTO_TEST_CASE(ccoins_write) |
Contributor
There was a problem hiding this comment.
Maybe try a loop of these tests with Child Flags not DIRTY as well
Contributor
|
ACK (left a couple of comments to slightly increase test coverage) |
03ffa4c to
07df40b
Compare
laanwj
added a commit
that referenced
this pull request
Dec 21, 2016
07df40b [test] Add CCoinsViewCache Access/Modify/Write tests (Russell Yanofsky)
Contributor
|
@ryanofsky What about this warning? Do you plan to use it or can it be removed? |
ryanofsky
added a commit
to ryanofsky/bitcoin
that referenced
this pull request
Dec 27, 2016
Pointed out by Pavel Janík <[email protected]> in bitcoin#9308.
Contributor
Author
|
I do have some debug code using it, which I might make a PR from later, but its better to remove for now since it's causing this warning. Created to #9435 to remove. |
ryanofsky
added a commit
to ryanofsky/bitcoin
that referenced
this pull request
Dec 27, 2016
Pointed out by Pavel Janík <[email protected]> in bitcoin#9308.
ryanofsky
added a commit
to ryanofsky/bitcoin
that referenced
this pull request
Jan 2, 2017
Remove unused variable in test, fixing warning. Pointed out by Pavel Janík <[email protected]> in bitcoin#9308.
codablock
pushed a commit
to codablock/dash
that referenced
this pull request
Oct 23, 2017
07df40b [test] Add CCoinsViewCache Access/Modify/Write tests (Russell Yanofsky)
lateminer
pushed a commit
to lateminer/bitcoin
that referenced
this pull request
Jan 4, 2019
Pointed out by Pavel Janík <[email protected]> in bitcoin#9308.
random-zebra
pushed a commit
to random-zebra/PIVX
that referenced
this pull request
Aug 9, 2020
Pointed out by Pavel Janík <[email protected]> in bitcoin#9308.
random-zebra
pushed a commit
to random-zebra/PIVX
that referenced
this pull request
Aug 10, 2020
Pointed out by Pavel Janík <[email protected]> in bitcoin#9308.
random-zebra
pushed a commit
to random-zebra/PIVX
that referenced
this pull request
Aug 12, 2020
Pointed out by Pavel Janík <[email protected]> in bitcoin#9308.
random-zebra
added a commit
to PIVX-Project/PIVX
that referenced
this pull request
Aug 18, 2020
cdbb1a6 Remove unused variable in test, fixing warning. (Russell Yanofsky) 03031a5 Check FRESH validity in CCoinsViewCache::BatchWrite (Russell Yanofsky) 3fb3e03 Fix dangerous condition in ModifyNewCoins. (random-zebra) 228d6bc [test] Add CCoinsViewCache Access/Modify/Write tests (random-zebra) Pull request description: Going on with the coins view cache update work (started with #1774 and #1777). This backports the following upstream PRs (adapting them with the assumption that duplicate coinbase transactions are not possible): - bitcoin#9308 - [test] Add CCoinsViewCache Access/Modify/Write tests - bitcoin#9107 - Safer modify new coins - bitcoin#9310 - Assert FRESH validity in CCoinsViewCache::BatchWrite - bitcoin#9435 - Removed unused variable in test, fixing warning. Note: Will rebase #1773 on top of this one (to change `ApplyTxInUndo` return value in the unit test too). ACKs for top commit: furszy: pretty nice one, ACK cdbb1a6 Fuzzbawls: ACK cdbb1a6 Tree-SHA512: 69c534da1083c3c4a535923e98da7750474c6698bb45e042778b539a27fab0455d78aaf670bed9485522f9d2ee25e4ad57fa7d35632523fe7376fe5f5febb1e5
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Add more comprehensive unit tests for CCoinsViewCache. Right now it is hard to refactor caching code or fix bugs in the caching logic because you have to try to mentally enumerate all the different states the cache might be in to make sure a change doesn't cause unintended consequences. The new tests explicitly enumerate relevant cache states, documenting and verifying the behavior in each state, so it will be safer and easier to make changes to the caching code in the future.