From 3e4155fcefe0aafcc9cb84640e303e05477605a3 Mon Sep 17 00:00:00 2001 From: Andrew Toth Date: Sat, 3 Jan 2026 20:26:33 +0100 Subject: [PATCH] test: do not return spent coins from `CCoinsViewTest::GetCoin` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/test/coins_tests.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 6396fce60ac..63024054fa6 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -48,11 +48,7 @@ public: std::optional 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; }