Bitcoin Core  22.99.0
P2P Digital Currency
policy_estimator_io.cpp
Go to the documentation of this file.
1 // Copyright (c) 2020-2021 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>
7 #include <test/fuzz/fuzz.h>
8 #include <test/fuzz/util.h>
10 
11 #include <cstdint>
12 #include <vector>
13 
15 {
16  static const auto testing_setup = MakeNoLogFileContext<>();
17 }
18 
20 {
21  FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
22  FuzzedAutoFileProvider fuzzed_auto_file_provider = ConsumeAutoFile(fuzzed_data_provider);
23  CAutoFile fuzzed_auto_file = fuzzed_auto_file_provider.open();
24  // Re-using block_policy_estimator across runs to avoid costly creation of CBlockPolicyEstimator object.
25  static CBlockPolicyEstimator block_policy_estimator;
26  if (block_policy_estimator.Read(fuzzed_auto_file)) {
27  block_policy_estimator.Write(fuzzed_auto_file);
28  }
29 }
FUZZ_TARGET_INIT
FUZZ_TARGET_INIT(policy_estimator_io, initialize_policy_estimator_io)
Definition: policy_estimator_io.cpp:19
setup_common.h
util.h
CBlockPolicyEstimator::Write
bool Write(CAutoFile &fileout) const
Write estimation data to a file.
Definition: fees.cpp:894
CAutoFile
Non-refcounted RAII wrapper for FILE*.
Definition: streams.h:564
initialize_policy_estimator_io
void initialize_policy_estimator_io()
Definition: policy_estimator_io.cpp:14
FuzzedDataProvider.h
CBlockPolicyEstimator
Definition: fees.h:131
FuzzedAutoFileProvider
Definition: util.h:306
fees.h
ConsumeAutoFile
FuzzedAutoFileProvider ConsumeAutoFile(FuzzedDataProvider &fuzzed_data_provider) noexcept
Definition: util.h:322
fuzz.h
FuzzedDataProvider
Definition: FuzzedDataProvider.h:31
CBlockPolicyEstimator::Read
bool Read(CAutoFile &filein)
Read estimation data from a file.
Definition: fees.cpp:919
FuzzedAutoFileProvider::open
CAutoFile open()
Definition: util.h:316