diff options
author | Antoine Poinsot <darosior@protonmail.com> | 2023-08-04 13:51:30 +0200 |
---|---|---|
committer | Antoine Poinsot <darosior@protonmail.com> | 2023-08-04 13:51:30 +0200 |
commit | c5f6b1db56f67f529377bfb61f58c0a8c17b0127 (patch) | |
tree | b16b3f8fcefdb95d7c16ccfae30fdfe965644ead | |
parent | a4ca4975880c4f870c6047065c70610af2529e74 (diff) |
fuzz: coins_view: correct an incorrect assertion
It is incorrect to assert that `cache.HaveCoin()` will always be `true`
if `backend.HaveCoin()` is. The coin could well have been marked as
spent in the cache but not yet flushed, in which case `cache.HaveCoin()`
would return `false`.
Note this was never hit because `exists_using_have_coin_in_backend` is
currently never `true` (it's the default implementation of `CCoinsView`.
However this might change if we were to add a target where the backend
is a `CCoinsViewDB`.
-rw-r--r-- | src/test/fuzz/coins_view.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/test/fuzz/coins_view.cpp b/src/test/fuzz/coins_view.cpp index 723dc6420f..c0dff7e485 100644 --- a/src/test/fuzz/coins_view.cpp +++ b/src/test/fuzz/coins_view.cpp @@ -155,8 +155,9 @@ 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) || (!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); - if (exists_using_have_coin_in_backend) { + if (!coin_using_access_coin.IsSpent() && exists_using_have_coin_in_backend) { assert(exists_using_have_coin); } Coin coin_using_backend_get_coin; |