mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
Merge bitcoin/bitcoin#28215: fuzz: fix a couple incorrect assertions in the coins_view
target
e417c988f6
fuzz: coins_view: remove an incorrect assertion (Antoine Poinsot)c5f6b1db56
fuzz: coins_view: correct an incorrect assertion (Antoine Poinsot) Pull request description: The `coins_view` fuzz target would assert in two places that the cache is consistent with the backend. But it's never the case (that's the whole point of using a cache). The only reason this didn't result in a crash was that we would never actually hit these assertions. I ran into this while introducing a new target with an in-memory `CCoinsViewDB` as the backend view (see https://github.com/bitcoin/bitcoin/pull/28216) which made the code paths with those assertions actually reachable. ACKs for top commit: dergoegge: Code review ACKe417c988f6
Tree-SHA512: 5847bb2744a2f2831dace62d32b79cc491bf54e2af4ce425411d245d566622d9aff816d9be5ec8e830d10851c13f2500bf4f0c004d88b4d7cca1d483ef8960a6
This commit is contained in:
commit
e38c225261
1 changed files with 4 additions and 2 deletions
|
@ -155,14 +155,16 @@ FUZZ_TARGET(coins_view, .init = initialize_coins_view)
|
||||||
}
|
}
|
||||||
assert((exists_using_access_coin && exists_using_have_coin_in_cache && exists_using_have_coin && exists_using_get_coin) ||
|
assert((exists_using_access_coin && exists_using_have_coin_in_cache && exists_using_have_coin && exists_using_get_coin) ||
|
||||||
(!exists_using_access_coin && !exists_using_have_coin_in_cache && !exists_using_have_coin && !exists_using_get_coin));
|
(!exists_using_access_coin && !exists_using_have_coin_in_cache && !exists_using_have_coin && !exists_using_get_coin));
|
||||||
|
// If HaveCoin on the backend is true, it must also be on the cache if the coin wasn't spent.
|
||||||
const bool exists_using_have_coin_in_backend = backend_coins_view.HaveCoin(random_out_point);
|
const bool exists_using_have_coin_in_backend = backend_coins_view.HaveCoin(random_out_point);
|
||||||
if (exists_using_have_coin_in_backend) {
|
if (!coin_using_access_coin.IsSpent() && exists_using_have_coin_in_backend) {
|
||||||
assert(exists_using_have_coin);
|
assert(exists_using_have_coin);
|
||||||
}
|
}
|
||||||
Coin coin_using_backend_get_coin;
|
Coin coin_using_backend_get_coin;
|
||||||
if (backend_coins_view.GetCoin(random_out_point, coin_using_backend_get_coin)) {
|
if (backend_coins_view.GetCoin(random_out_point, coin_using_backend_get_coin)) {
|
||||||
assert(exists_using_have_coin_in_backend);
|
assert(exists_using_have_coin_in_backend);
|
||||||
assert(coin_using_get_coin == coin_using_backend_get_coin);
|
// Note we can't assert that `coin_using_get_coin == coin_using_backend_get_coin` because the coin in
|
||||||
|
// the cache may have been modified but not yet flushed.
|
||||||
} else {
|
} else {
|
||||||
assert(!exists_using_have_coin_in_backend);
|
assert(!exists_using_have_coin_in_backend);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue