fuzz: call `EmplaceCoinInternalDANGER` as well in `SimulationTest`
What changed, and why it matters
This change only adds a new test path inside an existing fuzz test. It makes the test randomly call an internal helper named EmplaceCoinInternalDANGER instead of always using AddCoin. There is no change to production code, no bug fix, and no security-relevant behavior in the commit itself.
No action required; this is a test-only change. If reviewing the future commit that modifies EmplaceCoinInternalDANGER, ensure that change is reviewed for safety.
Security signals we found
No production code changed
Test-only fuzz coverage addition
Function name contains 'DANGER' but is only invoked in a test
No validation, consensus, or networking code modified
Evidence from the diff
The commit modifies src/test/coins_tests.cpp’s SimulationTest fuzz target. Previously the test always called CCoinsViewCache::AddCoin. Now, when a COutPoint is not already present in the cache map, the new coin is not unspendable, and a random boolean is true, it calls EmplaceCoinInternalDANGER; otherwise it falls back to AddCoin. The commit message explicitly states this is to add test coverage ahead of future modifications. No production logic is changed.
Changed components
src/test/coins_tests.cppInspect captured patch +5 / −2
diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp
index 8c0756d8..d5219fce 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;
Why this scored 13/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.