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 <node/mempool_persist.h>6#include <test/util/time.h>8#include <node/mempool_args.h>9#include <node/mempool_persist_args.h>10#include <test/fuzz/FuzzedDataProvider.h>11#include <test/fuzz/fuzz.h>12#include <test/fuzz/util.h>13#include <test/fuzz/util/mempool.h>14#include <test/util/setup_common.h>15#include <test/util/txmempool.h>16#include <txmempool.h>17#include <util/check.h>18#include <util/time.h>19#include <util/translation.h>20#include <validation.h>22#include <cstdint>23#include <vector>25using node::DumpMempool;26using node::LoadMempool;28using node::MempoolPath;30namespace {31const TestingSetup* g_setup;32} // namespace34void initialize_validation_load_mempool()35{36static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();37g_setup = testing_setup.get();38}40FUZZ_TARGET(validation_load_mempool, .init = initialize_validation_load_mempool)41{42SeedRandomStateForTest(SeedRand::ZEROS);43FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};44FakeNodeClock clock{ConsumeTime(fuzzed_data_provider)};45FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};47bilingual_str error;48CTxMemPool pool{MemPoolOptionsForTest(g_setup->m_node), error};49Assert(error.empty());51auto& chainstate{static_cast<DummyChainState&>(g_setup->m_node.chainman->ActiveChainstate())};52chainstate.SetMempool(&pool);54auto fuzzed_fopen = [&](const fs::path&, const char*) {55return fuzzed_file_provider.open();56};57(void)LoadMempool(pool, MempoolPath(g_setup->m_args), chainstate,58{59.mockable_fopen_function = fuzzed_fopen,60});61pool.SetLoadTried(true);62(void)DumpMempool(pool, MempoolPath(g_setup->m_args), fuzzed_fopen, true);63}
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.