fuzz: mock CBlockPolicyEstimator in wallet_fuzz
What changed, and why it matters
This commit only changes a fuzz test file. It introduces a fake/mock version of Bitcoin Core's fee estimator so the wallet fuzz test can control its outputs. There is no change to production code, no user-facing behavior change, and no security fix or vulnerability.
No action needed; this is a benign fuzz-testing improvement. Continue normal review/merge process.
Security signals we found
No security-relevant change: only test code modified
No memory safety, cryptographic, consensus, or networking changes
No bug fix or vulnerability remediation present in diff
Evidence from the diff
The diff adds a FuzzedBlockPolicyEstimator class inside src/wallet/test/fuzz/fees.cpp that overrides estimateSmartFee and HighestTargetTracked to return fuzzer-controlled values. The wallet fuzz target then installs this mock into node.fee_estimator. This is purely a testing infrastructure change to improve fuzzing coverage and determinism; it does not modify any real consensus, networking, wallet, or mempool logic.
Changed components
src/wallet/test/fuzz/fees.cppInspect captured patch +21 / −0
diff --git a/src/wallet/test/fuzz/fees.cpp b/src/wallet/test/fuzz/fees.cpp
index e98dbe02..515c3b19 100644
--- a/src/wallet/test/fuzz/fees.cpp
+++ b/src/wallet/test/fuzz/fees.cpp
@@ -16,6 +16,25 @@ namespace wallet {
namespace {
TestingSetup* g_setup;
+class FuzzedBlockPolicyEstimator : public CBlockPolicyEstimator
+{
+ FuzzedDataProvider& fuzzed_data_provider;
+
+public:
+ FuzzedBlockPolicyEstimator(FuzzedDataProvider& provider)
+ : CBlockPolicyEstimator(fs::path{}, false), fuzzed_data_provider(provider) {}
+
+ CFeeRate estimateSmartFee(int confTarget, FeeCalculation* feeCalc, bool conservative) const override
+ {
+ return CFeeRate{ConsumeMoney(fuzzed_data_provider, /*max=*/1'000'000)};
+ }
+
+ unsigned int HighestTargetTracked(FeeEstimateHorizon horizon) const override
+ {
+ return fuzzed_data_provider.ConsumeIntegralInRange<unsigned int>(1, 1000);
+ }
+};
+
void initialize_setup()
{
static const auto testing_setup = MakeNoLogFileContext<TestingSetup>();
@@ -37,6 +56,8 @@ FUZZ_TARGET(wallet_fees, .init = initialize_setup)
.dust_relay_feerate = CFeeRate{ConsumeMoney(fuzzed_data_provider, 1'000'000)}
};
node.mempool = std::make_unique<CTxMemPool>(mempool_opts, error);
+ std::unique_ptr<CBlockPolicyEstimator> fee_estimator = std::make_unique<FuzzedBlockPolicyEstimator>(fuzzed_data_provider);
+ node.fee_estimator = std::move(fee_estimator);
std::unique_ptr<CWallet> wallet_ptr{std::make_unique<CWallet>(node.chain.get(), "", CreateMockableWalletDatabase())};
CWallet& wallet{*wallet_ptr};
{
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.