fuzz: create FeeEstimatorTestingSetup to set fee_estimator
What changed, and why it matters
This commit is a small cleanup inside a fuzz test (automated randomized testing) for Bitcoin Core's wallet fee logic. It creates a dedicated test helper class so the fuzz harness can safely set and reset the fee estimator. There is no change to production code, no user-facing behavior change, and no security fix.
No action required. This is a test-only refactoring with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors src/wallet/test/fuzz/fees.cpp. It introduces FeeEstimatorTestingSetup, derived from TestingSetup, with a destructor that resets m_node.fee_estimator and a setter for the fee estimator. The fuzz target now uses this setup instead of directly assigning to node.fee_estimator. This only affects test infrastructure and resource cleanup in fuzzing runs.
Changed components
src/wallet/test/fuzz/fees.cppInspect captured patch +19 / −3
diff --git a/src/wallet/test/fuzz/fees.cpp b/src/wallet/test/fuzz/fees.cpp
index 515c3b19..9cf7e89d 100644
--- a/src/wallet/test/fuzz/fees.cpp
+++ b/src/wallet/test/fuzz/fees.cpp
@@ -14,7 +14,23 @@
namespace wallet {
namespace {
-TestingSetup* g_setup;
+
+struct FeeEstimatorTestingSetup : public TestingSetup {
+ FeeEstimatorTestingSetup(const ChainType chain_type, TestOpts opts) : TestingSetup{chain_type, opts}
+ {
+ }
+
+ ~FeeEstimatorTestingSetup() {
+ m_node.fee_estimator.reset();
+ }
+
+ void SetFeeEstimator(std::unique_ptr<CBlockPolicyEstimator> fee_estimator)
+ {
+ m_node.fee_estimator = std::move(fee_estimator);
+ }
+};
+
+FeeEstimatorTestingSetup* g_setup;
class FuzzedBlockPolicyEstimator : public CBlockPolicyEstimator
{
@@ -37,7 +53,7 @@ public:
void initialize_setup()
{
- static const auto testing_setup = MakeNoLogFileContext<TestingSetup>();
+ static const auto testing_setup = MakeNoLogFileContext<FeeEstimatorTestingSetup>();
g_setup = testing_setup.get();
}
@@ -57,7 +73,7 @@ FUZZ_TARGET(wallet_fees, .init = initialize_setup)
};
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);
+ g_setup->SetFeeEstimator(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.