fuzz: pass coins_view_cache to TestCoinsView in coins_view
What changed, and why it matters
This commit is a minor code cleanup in Bitcoin Core's internal fuzz testing code. It changes how a test helper function receives a temporary data cache, moving the cache creation from inside the helper to the callers. The commit message explicitly calls this a non-functional change, and the diff shows only a straightforward parameter refactor with no logic changes to how Bitcoin handles transactions, networking, or wallets.
No action needed. This is a non-functional test refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors TestCoinsView() in src/test/fuzz/coins_view.cpp to take a CCoinsViewCache reference as a parameter rather than constructing it internally. Both fuzz targets (coins_view and coins_view_db) are updated to instantiate the cache before calling TestCoinsView(). The same cache is still created with identical arguments (deterministic=true), and all other behavior inside TestCoinsView() remains unchanged. This is purely a structural change to enable future fuzz targets that may pass a different cache type.
Changed components
src/test/fuzz/coins_view.cppInspect captured patch +6 / −5
diff --git a/src/test/fuzz/coins_view.cpp b/src/test/fuzz/coins_view.cpp
index 699a45e2..813cf031 100644
--- a/src/test/fuzz/coins_view.cpp
+++ b/src/test/fuzz/coins_view.cpp
@@ -42,11 +42,10 @@ void initialize_coins_view()
static const auto testing_setup = MakeNoLogFileContext<>();
}
-void TestCoinsView(FuzzedDataProvider& fuzzed_data_provider, CCoinsView& backend_coins_view, bool is_db)
+void TestCoinsView(FuzzedDataProvider& fuzzed_data_provider, CCoinsViewCache& coins_view_cache, CCoinsView& backend_coins_view, bool is_db)
{
bool good_data{true};
- CCoinsViewCache coins_view_cache{&backend_coins_view, /*deterministic=*/true};
if (is_db) coins_view_cache.SetBestBlock(uint256::ONE);
COutPoint random_out_point;
Coin random_coin;
@@ -312,7 +311,8 @@ FUZZ_TARGET(coins_view, .init = initialize_coins_view)
{
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
CCoinsView backend_coins_view;
- TestCoinsView(fuzzed_data_provider, backend_coins_view, /*is_db=*/false);
+ CCoinsViewCache coins_view_cache{&backend_coins_view, /*deterministic=*/true};
+ TestCoinsView(fuzzed_data_provider, coins_view_cache, backend_coins_view, /*is_db=*/false);
}
FUZZ_TARGET(coins_view_db, .init = initialize_coins_view)
@@ -323,6 +323,7 @@ FUZZ_TARGET(coins_view_db, .init = initialize_coins_view)
.cache_bytes = 1_MiB,
.memory_only = true,
};
- CCoinsViewDB coins_db{std::move(db_params), CoinsViewOptions{}};
- TestCoinsView(fuzzed_data_provider, coins_db, /*is_db=*/true);
+ CCoinsViewDB backend_coins_view{std::move(db_params), CoinsViewOptions{}};
+ CCoinsViewCache coins_view_cache{&backend_coins_view, /*deterministic=*/true};
+ TestCoinsView(fuzzed_data_provider, coins_view_cache, backend_coins_view, /*is_db=*/true);
}
Why this scored 15/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.