Bitcoin Core 22.99.0
P2P Digital Currency
validation_load_mempool.cpp
Go to the documentation of this file.
1// Copyright (c) 2020 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <chainparamsbase.h>
7#include <test/fuzz/fuzz.h>
8#include <test/fuzz/util.h>
10#include <txmempool.h>
11#include <util/time.h>
12#include <validation.h>
13
14#include <cstdint>
15#include <vector>
16
17namespace {
18const TestingSetup* g_setup;
19} // namespace
20
22{
23 static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
24 g_setup = testing_setup.get();
25}
26
28{
29 FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
30 SetMockTime(ConsumeTime(fuzzed_data_provider));
31 FuzzedFileProvider fuzzed_file_provider = ConsumeFile(fuzzed_data_provider);
32
33 CTxMemPool pool{};
34 auto fuzzed_fopen = [&](const fs::path&, const char*) {
35 return fuzzed_file_provider.open();
36 };
37 (void)LoadMempool(pool, g_setup->m_node.chainman->ActiveChainstate(), fuzzed_fopen);
38 (void)DumpMempool(pool, fuzzed_fopen, true);
39}
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:424
FILE * open()
Definition: util.cpp:396
Path class wrapper to prepare application code for transition from boost::filesystem library to std::...
Definition: fs.h:34
Testing setup that configures a complete environment.
Definition: setup_common.h:99
int64_t ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
Definition: util.cpp:227
FuzzedFileProvider ConsumeFile(FuzzedDataProvider &fuzzed_data_provider) noexcept
Definition: util.h:301
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
Definition: time.cpp:101
bool LoadMempool(CTxMemPool &pool, CChainState &active_chainstate, FopenFn mockable_fopen_function)
Load the mempool from disk.
bool DumpMempool(const CTxMemPool &pool, FopenFn mockable_fopen_function, bool skip_file_commit)
Dump the mempool to disk.
FUZZ_TARGET_INIT(validation_load_mempool, initialize_validation_load_mempool)
void initialize_validation_load_mempool()