Bitcoin Core  27.99.0
P2P Digital Currency
policy_estimator_io.cpp
Go to the documentation of this file.
1 // Copyright (c) 2020-2022 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 <policy/fees.h>
6 #include <policy/fees_args.h>
7 #include <streams.h>
9 #include <test/fuzz/fuzz.h>
10 #include <test/fuzz/util.h>
11 #include <test/util/setup_common.h>
12 
13 #include <memory>
14 
15 namespace {
16 const BasicTestingSetup* g_setup;
17 } // namespace
18 
20 {
21  static const auto testing_setup = MakeNoLogFileContext<>();
22  g_setup = testing_setup.get();
23 }
24 
26 {
27  FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
28  FuzzedFileProvider fuzzed_file_provider{fuzzed_data_provider};
29  AutoFile fuzzed_auto_file{fuzzed_file_provider.open()};
30  // Re-using block_policy_estimator across runs to avoid costly creation of CBlockPolicyEstimator object.
31  static CBlockPolicyEstimator block_policy_estimator{FeeestPath(*g_setup->m_node.args), DEFAULT_ACCEPT_STALE_FEE_ESTIMATES};
32  if (block_policy_estimator.Read(fuzzed_auto_file)) {
33  block_policy_estimator.Write(fuzzed_auto_file);
34  }
35 }
Non-refcounted RAII wrapper for FILE*.
Definition: streams.h:389
The BlockPolicyEstimator is used for estimating the feerate needed for a transaction to be included i...
Definition: fees.h:149
fs::path FeeestPath(const ArgsManager &argsman)
Definition: fees_args.cpp:13
static constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES
Definition: fees.h:36
FUZZ_TARGET(policy_estimator_io,.init=initialize_policy_estimator_io)
void initialize_policy_estimator_io()
Basic testing setup.
Definition: setup_common.h:52