Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
policy_estimator.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
9#include <streams.h>
11#include <test/fuzz/fuzz.h>
12#include <test/fuzz/util.h>
15
16#include <memory>
17#include <optional>
18#include <vector>
19
20namespace {
22} // namespace
23
25{
26 static const auto testing_setup = MakeNoLogFileContext<>();
27 g_setup = testing_setup.get();
28}
29
31{
32 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
33 bool good_data{true};
34
36
38 const auto advance_height{
40 };
43 {
46 [&] {
48 if (!mtx) {
49 good_data = false;
50 return;
51 }
52 const CTransaction tx{*mtx};
56 const auto tx_info = NewMempoolTransactionInfo(entry.GetSharedTx(), entry.GetFee(),
57 entry.GetTxSize(), entry.GetHeight(),
58 /*mempool_limit_bypassed=*/false,
60 /*chainstate_is_current=*/true,
62 block_policy_estimator.processTransaction(tx_info);
64 (void)block_policy_estimator.removeTx(tx.GetHash());
65 }
66 },
67 [&] {
68 std::list<CTxMemPoolEntry> mempool_entries;
70 {
72 if (!mtx) {
73 good_data = false;
74 break;
75 }
76 const CTransaction tx{*mtx};
78 }
79 std::vector<RemovedMempoolTransactionInfo> txs;
80 txs.reserve(mempool_entries.size());
82 txs.emplace_back(mempool_entry);
83 }
86 },
87 [&] {
89 },
90 [&] {
91 block_policy_estimator.FlushUnconfirmed();
92 });
94 EstimationResult result;
98 auto* result_ptr = fuzzed_data_provider.ConsumeBool() ? &result : nullptr;
100
106
108 }
109 {
115 }
116}
const TestingSetup * g_setup
static constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES
static constexpr auto ALL_FEE_ESTIMATE_HORIZONS
fs::path FeeestPath(const ArgsManager &argsman)
Non-refcounted RAII wrapper for FILE*.
Definition streams.h:373
int fclose()
Definition streams.h:407
The BlockPolicyEstimator is used for estimating the feerate needed for a transaction to be included i...
The basic transaction that is broadcasted on the network and contained in blocks.
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
T ConsumeIntegralInRange(T min, T max)
T PickValueInArray(const T(&array)[size])
static transaction_identifier FromUint256(const uint256 &id)
#define FUZZ_TARGET(...)
Definition fuzz.h:35
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
Definition fuzz.h:22
void initialize_policy_estimator()
static constexpr TransactionSerParams TX_WITH_WITNESS
Basic testing setup.
node::NodeContext m_node
ArgsManager * args
Definition context.h:74
CTxMemPoolEntry ConsumeTxMemPoolEntry(FuzzedDataProvider &fuzzed_data_provider, const CTransaction &tx, uint32_t max_height) noexcept
Definition mempool.cpp:17
uint256 ConsumeUInt256(FuzzedDataProvider &fuzzed_data_provider) noexcept
Definition util.h:167
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
Definition util.h:35
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:73
FuzzedDataProvider & fuzzed_data_provider
Definition fees.cpp:38