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 
17 namespace {
18 const 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 }
FUZZ_TARGET_INIT
FUZZ_TARGET_INIT(validation_load_mempool, initialize_validation_load_mempool)
Definition: validation_load_mempool.cpp:27
setup_common.h
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:478
chainparamsbase.h
util.h
initialize_validation_load_mempool
void initialize_validation_load_mempool()
Definition: validation_load_mempool.cpp:21
txmempool.h
ConsumeTime
int64_t ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
Definition: util.cpp:226
LoadMempool
bool LoadMempool(CTxMemPool &pool, CChainState &active_chainstate, FopenFn mockable_fopen_function)
Load the mempool from disk.
Definition: validation.cpp:4383
ConsumeFile
FuzzedFileProvider ConsumeFile(FuzzedDataProvider &fuzzed_data_provider) noexcept
Definition: util.h:301
SetMockTime
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
Definition: time.cpp:101
FuzzedDataProvider.h
time.h
FuzzedFileProvider::open
FILE * open()
Definition: util.cpp:395
fuzz.h
FuzzedDataProvider
Definition: FuzzedDataProvider.h:31
DumpMempool
bool DumpMempool(const CTxMemPool &pool, FopenFn mockable_fopen_function, bool skip_file_commit)
Dump the mempool to disk.
Definition: validation.cpp:4467
TestingSetup
Testing setup that configures a complete environment.
Definition: setup_common.h:99
FuzzedFileProvider
Definition: util.h:280