Bitcoin Core 32.99.0
P2P Digital Currency
Loading...
Searching...
No Matches
block_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
6
10#include <streams.h>
12#include <test/fuzz/fuzz.h>
13#include <test/fuzz/util.h>
16
17#include <memory>
18#include <optional>
19#include <vector>
20
21namespace {
23} // namespace
24
26{
27 static const auto testing_setup = MakeNoLogFileContext<>();
28 g_setup = testing_setup.get();
29}
30
32{
33 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
34 bool good_data{true};
35
37
39 const auto advance_height{
41 };
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;
71 if (!mtx) {
72 good_data = false;
73 break;
74 }
75 const CTransaction tx{*mtx};
77 }
78 std::vector<RemovedMempoolTransactionInfo> txs;
79 txs.reserve(mempool_entries.size());
81 txs.emplace_back(mempool_entry);
82 }
85 },
86 [&] {
88 },
89 [&] {
90 block_policy_estimator.FlushUnconfirmed();
91 });
93 EstimationResult result;
97 auto* result_ptr = fuzzed_data_provider.ConsumeBool() ? &result : nullptr;
99
105
107 }
108 {
114 }
115}
const TestingSetup * g_setup
constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES
constexpr auto ALL_FEE_ESTIMATE_HORIZONS
Non-refcounted RAII wrapper for FILE*.
Definition streams.h:395
int fclose()
Definition streams.h:429
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)
uint32_t current_height
Current height in the simulation.
fs::path BlockPolicyFeeEstPath(const ArgsManager &argsman)
#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
Definition basic.cpp:11
constexpr TransactionSerParams TX_WITH_WITNESS
Basic testing setup.
node::NodeContext m_node
ArgsManager * args
Definition context.h:76
void initialize_block_policy_estimator()
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:195
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
Definition util.h:37
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:82
FuzzedDataProvider & fuzzed_data_provider
Definition fees.cpp:46