fuzz: set mempool options in wallet_fees
What changed, and why it matters
This commit changes a Bitcoin Core fuzz test (an automated test that feeds random data to a piece of code to find crashes or bugs). It removes a 'const' restriction so the test can create a fresh, configurable memory pool (mempool) for each fuzz run, and sets fee-related options from the fuzz input. It is a test-only change and does not alter the behavior of the actual Bitcoin node software that users run.
No action required. Treat as a routine fuzz-test improvement. Reviewers may verify that the non-const node reference and mempool replacement do not introduce use-after-free or lifetime issues within the test fixture.
Security signals we found
Test-only modification with no production code changes
Removal of const qualifier to permit mutable test fixture
Fuzzer-controlled mempool fee parameters increase coverage of wallet fee estimation paths
Evidence from the diff
In src/wallet/test/fuzz/fees.cpp, the global g_setup is changed from const TestingSetup to TestingSetup, and MakeNoLogFileContext is instantiated without const. The fuzz target now takes node by non-const reference and constructs a new CTxMemPool with fuzzer-controlled incremental_relay_feerate, min_relay_feerate, and dust_relay_feerate before exercising wallet fee logic. This increases test coverage by allowing the fuzzer to vary mempool parameters, but the change is confined to the test harness.
Changed components
src/wallet/test/fuzz/fees.cppInspect captured patch +11 / −3
diff --git a/src/wallet/test/fuzz/fees.cpp b/src/wallet/test/fuzz/fees.cpp
index 80458ac8..e98dbe02 100644
--- a/src/wallet/test/fuzz/fees.cpp
+++ b/src/wallet/test/fuzz/fees.cpp
@@ -14,11 +14,11 @@
namespace wallet {
namespace {
-const TestingSetup* g_setup;
+TestingSetup* g_setup;
void initialize_setup()
{
- static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
+ static const auto testing_setup = MakeNoLogFileContext<TestingSetup>();
g_setup = testing_setup.get();
}
@@ -27,8 +27,16 @@ FUZZ_TARGET(wallet_fees, .init = initialize_setup)
SeedRandomStateForTest(SeedRand::ZEROS);
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
SetMockTime(ConsumeTime(fuzzed_data_provider));
- const auto& node{g_setup->m_node};
+ auto& node{g_setup->m_node};
Chainstate* chainstate = &node.chainman->ActiveChainstate();
+
+ bilingual_str error;
+ CTxMemPool::Options mempool_opts{
+ .incremental_relay_feerate = CFeeRate{ConsumeMoney(fuzzed_data_provider, 1'000'000)},
+ .min_relay_feerate = CFeeRate{ConsumeMoney(fuzzed_data_provider, 1'000'000)},
+ .dust_relay_feerate = CFeeRate{ConsumeMoney(fuzzed_data_provider, 1'000'000)}
+ };
+ node.mempool = std::make_unique<CTxMemPool>(mempool_opts, error);
std::unique_ptr<CWallet> wallet_ptr{std::make_unique<CWallet>(node.chain.get(), "", CreateMockableWalletDatabase())};
CWallet& wallet{*wallet_ptr};
{
Why this scored 16/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.