From 7e52b1b945c4137e0fb05715090635ce82ed04b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Tue, 30 Sep 2025 17:38:36 -0400 Subject: [PATCH] fuzz: call `EmplaceCoinInternalDANGER` as well in `SimulationTest` Adds test coverage by randomly calling `EmplaceCoinInternalDANGER` in `SimulationTest` to verify it remains correct as we modify it in a future commit. Co-authored-by: Andrew Toth --- src/test/coins_tests.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 8c0756d8528..d5219fceb07 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -189,8 +189,11 @@ void SimulationTest(CCoinsView* base, bool fake_best_block) (coin.IsSpent() ? added_an_entry : updated_an_entry) = true; coin = newcoin; } - bool is_overwrite = !coin.IsSpent() || m_rng.rand32() & 1; - stack.back()->AddCoin(COutPoint(txid, 0), std::move(newcoin), is_overwrite); + if (COutPoint op(txid, 0); !stack.back()->map().contains(op) && !newcoin.out.scriptPubKey.IsUnspendable() && m_rng.randbool()) { + stack.back()->EmplaceCoinInternalDANGER(std::move(op), std::move(newcoin)); + } else { + stack.back()->AddCoin(op, std::move(newcoin), /*possible_overwrite=*/!coin.IsSpent() || m_rng.randbool()); + } } else { // Spend the coin. removed_an_entry = true;