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:
1 parent
ee1e40f580
commit
3e4155fcef
1 file changed
+1
-5
@@ -48,11 +48,7 @@ public:
|
|||||||
|
|
||||||
std::optional<Coin> GetCoin(const COutPoint& outpoint) const override
|
std::optional<Coin> GetCoin(const COutPoint& outpoint) const override
|
||||||
{
|
{
|
||||||
if (auto it{map_.find(outpoint)}; it != map_.end()) {
|
if (auto it{map_.find(outpoint)}; it != map_.end() && !it->second.IsSpent()) return it->second;
|
||||||
if (!it->second.IsSpent() || m_rng.randbool()) {
|
|
||||||
return it->second; // TODO spent coins shouldn't be returned
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user