mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-04 04:45:10 +02:00
test: do not return spent coins from CCoinsViewTest::GetCoin
Production `GetCoin()` implementations only return unspent coins. Update the `CCoinsView` test backend to match that contract, so tests stop exercising cache states that cannot occur with `CCoinsViewCache` or `CCoinsViewDB`. Co-authored-by: Lőrinc <pap.lorinc@gmail.com>
This commit is contained in:
@@ -48,11 +48,7 @@ public:
|
||||
|
||||
std::optional<Coin> GetCoin(const COutPoint& outpoint) const override
|
||||
{
|
||||
if (auto it{map_.find(outpoint)}; it != map_.end()) {
|
||||
if (!it->second.IsSpent() || m_rng.randbool()) {
|
||||
return it->second; // TODO spent coins shouldn't be returned
|
||||
}
|
||||
}
|
||||
if (auto it{map_.find(outpoint)}; it != map_.end() && !it->second.IsSpent()) return it->second;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user