test: simplify coins sanity check

This commit is contained in:
Andrew Toth 2024-08-31 14:20:12 -04:00
parent 147cd50501
commit 4c9c30eda3
No known key found for this signature in database
GPG key ID: 60007AFC8938B018

View file

@ -311,12 +311,13 @@ void CCoinsViewCache::SanityCheck() const
size_t recomputed_usage = 0;
size_t count_flagged = 0;
for (const auto& [_, entry] : cacheCoins) {
unsigned attr = 0;
if (entry.IsDirty()) attr |= 1;
if (entry.IsFresh()) attr |= 2;
if (entry.coin.IsSpent()) attr |= 4;
// Only 4 combinations are possible.
assert(attr != 2 && attr != 4 && attr != 6 && attr != 7);
if (entry.coin.IsSpent()) {
// A spent coin must be dirty and cannot be fresh
assert(entry.IsDirty() && !entry.IsFresh());
} else {
// An unspent coin must not be fresh if not dirty
assert(entry.IsDirty() || !entry.IsFresh());
}
// Recompute cachedCoinsUsage.
recomputed_usage += entry.coin.DynamicMemoryUsage();