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