Bitcoin Core
31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
src
test
fuzz
policy_estimator_io.cpp
Go to the documentation of this file.
1
// Copyright (c) 2020-present 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/block_policy_estimator.h
>
6
#include <
policy/fees/block_policy_estimator_args.h
>
7
#include <
streams.h
>
8
#include <
test/fuzz/FuzzedDataProvider.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
19
void
initialize_policy_estimator_io
()
20
{
21
static
const
auto
testing_setup =
MakeNoLogFileContext<>
();
22
g_setup
= testing_setup.get();
23
}
24
25
FUZZ_TARGET
(
policy_estimator_io
, .
init
=
initialize_policy_estimator_io
)
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
// Reusing 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
(
void
)
fuzzed_auto_file
.fclose();
36
}
FuzzedDataProvider.h
g_setup
const TestingSetup * g_setup
Definition
block_index_tree.cpp:21
block_policy_estimator.h
DEFAULT_ACCEPT_STALE_FEE_ESTIMATES
static constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES
Definition
block_policy_estimator.h:36
FeeestPath
fs::path FeeestPath(const ArgsManager &argsman)
Definition
block_policy_estimator_args.cpp:13
block_policy_estimator_args.h
AutoFile
Non-refcounted RAII wrapper for FILE*.
Definition
streams.h:373
CBlockPolicyEstimator
The BlockPolicyEstimator is used for estimating the feerate needed for a transaction to be included i...
Definition
block_policy_estimator.h:149
FuzzedDataProvider
Definition
FuzzedDataProvider.h:32
FuzzedFileProvider
Definition
util.h:261
fuzz.h
FUZZ_TARGET
#define FUZZ_TARGET(...)
Definition
fuzz.h:35
init
Definition
bitcoin-gui.cpp:17
initialize_policy_estimator_io
void initialize_policy_estimator_io()
Definition
policy_estimator_io.cpp:19
setup_common.h
streams.h
BasicTestingSetup
Basic testing setup.
Definition
setup_common.h:64
BasicTestingSetup::m_node
node::NodeContext m_node
Definition
setup_common.h:66
node::NodeContext::args
ArgsManager * args
Definition
context.h:74
util.h
Ticks
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition
time.h:73
fuzzed_data_provider
FuzzedDataProvider & fuzzed_data_provider
Definition
fees.cpp:38
Generated on Thu Apr 16 2026 09:42:38 for Bitcoin Core by
1.10.0