Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2020-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <policy/fees/block_policy_estimator.h>6#include <policy/fees/estimator_args.h>7#include <policy/fees/mempool_estimator.h>8#include <streams.h>9#include <test/fuzz/FuzzedDataProvider.h>10#include <test/fuzz/fuzz.h>11#include <test/fuzz/util.h>12#include <test/util/setup_common.h>14#include <memory>16namespace {17const TestingSetup* g_setup;18} // namespace20void initialize_policy_estimator_io()21{22static const auto testing_setup{23MakeNoLogFileContext<const TestingSetup>(ChainType::REGTEST, TestOpts{.setup_net = false})};24g_setup = testing_setup.get();25}27FUZZ_TARGET(policy_estimator_io, .init = initialize_policy_estimator_io)28{29FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());30FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};31// Reuse estimators across runs to avoid costly object creation.32static CBlockPolicyEstimator block_policy_estimator{33BlockPolicyFeeEstPath(*g_setup->m_node.args), DEFAULT_ACCEPT_STALE_FEE_ESTIMATES};34{35AutoFile fuzzed_auto_file_block_policy{fuzzed_file_provider.open()};36if (block_policy_estimator.Read(fuzzed_auto_file_block_policy)) {37block_policy_estimator.Write(fuzzed_auto_file_block_policy);38}39(void)fuzzed_auto_file_block_policy.fclose();40}41static MemPoolFeeRateEstimator mempool_feerate_estimator{42MempoolPolicyEstimatorPath(*g_setup->m_node.args),43*g_setup->m_node.mempool,44*g_setup->m_node.chainman};45{46AutoFile fuzzed_auto_file_mempool_policy{fuzzed_file_provider.open()};47if (mempool_feerate_estimator.Read(fuzzed_auto_file_mempool_policy)) {48mempool_feerate_estimator.Write(fuzzed_auto_file_mempool_policy);49}50// Write() does not take ownership; close explicitly because it may51// have written to the fuzzed file.52(void)fuzzed_auto_file_mempool_policy.fclose();53}54}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.