refactor: Remove unrealistic simulation state

In non-test code the input coin is never mutated - it's either replaced or ignored.
This commit is contained in:
Lőrinc 2024-09-08 21:57:11 +02:00
parent ab0b5706b2
commit e31bfb26c2

View file

@ -137,9 +137,8 @@ struct CacheLevel
/** Class for the base of the hierarchy (roughly simulating a memory-backed CCoinsViewDB). /** Class for the base of the hierarchy (roughly simulating a memory-backed CCoinsViewDB).
* *
* The initial state consists of the empty UTXO set, though coins whose output index * The initial state consists of the empty UTXO set.
* is 3 (mod 5) always have GetCoin() succeed (but returning an IsSpent() coin unless a UTXO * Coins whose output index is 4 (mod 5) have GetCoin() always succeed after being spent.
* exists). Coins whose output index is 4 (mod 5) have GetCoin() always succeed after being spent.
* This exercises code paths with spent, non-DIRTY cache entries. * This exercises code paths with spent, non-DIRTY cache entries.
*/ */
class CoinsViewBottom final : public CCoinsView class CoinsViewBottom final : public CCoinsView
@ -151,14 +150,10 @@ public:
{ {
auto it = m_data.find(outpoint); auto it = m_data.find(outpoint);
if (it == m_data.end()) { if (it == m_data.end()) {
if ((outpoint.n % 5) == 3) {
coin.Clear();
return true;
}
return false; return false;
} else { } else {
coin = it->second; coin = it->second;
return true; return true; // TODO GetCoin shouldn't return spent coins
} }
} }