Bitcoin Core
31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
src
test
fuzz
util
mempool.cpp
Go to the documentation of this file.
1
// Copyright (c) 2022-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 <
consensus/amount.h
>
6
#include <
consensus/consensus.h
>
7
#include <
kernel/mempool_entry.h
>
8
#include <
primitives/transaction.h
>
9
#include <
test/fuzz/FuzzedDataProvider.h
>
10
#include <
test/fuzz/util.h
>
11
#include <
test/fuzz/util/mempool.h
>
12
13
#include <cassert>
14
#include <cstdint>
15
#include <limits>
16
17
CTxMemPoolEntry
ConsumeTxMemPoolEntry
(
FuzzedDataProvider
&
fuzzed_data_provider
,
const
CTransaction
& tx,
uint32_t
max_height
)
noexcept
18
{
19
// Avoid:
20
// policy/feerate.cpp:28:34: runtime error: signed integer overflow: 34873208148477500 * 1000 cannot be represented in type 'long'
21
//
22
// Reproduce using CFeeRate(348732081484775, 10).GetFeePerK()
23
const
CAmount
fee
{
ConsumeMoney
(
fuzzed_data_provider
,
/*max=*/
std::numeric_limits<CAmount>::max() /
CAmount
{100'000})};
24
assert
(
MoneyRange
(
fee
));
25
const
int64_t
time =
fuzzed_data_provider
.
ConsumeIntegral
<
int64_t
>();
26
const
uint64_t
entry_sequence{
fuzzed_data_provider
.
ConsumeIntegral
<
uint64_t
>()};
27
const
auto
entry_height
{
fuzzed_data_provider
.
ConsumeIntegralInRange
<
uint32_t
>(0,
max_height
)};
28
const
bool
spends_coinbase
=
fuzzed_data_provider
.
ConsumeBool
();
29
const
unsigned
int
sig_op_cost
=
fuzzed_data_provider
.
ConsumeIntegralInRange
<
unsigned
int
>(0,
MAX_BLOCK_SIGOPS_COST
);
30
return
CTxMemPoolEntry
{
MakeTransactionRef
(tx),
fee
, time,
entry_height
, entry_sequence,
spends_coinbase
,
sig_op_cost
, {}};
31
}
FuzzedDataProvider.h
amount.h
MoneyRange
bool MoneyRange(const CAmount &nValue)
Definition
amount.h:27
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition
amount.h:12
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition
transaction.h:281
CTxMemPoolEntry
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
Definition
mempool_entry.h:66
FuzzedDataProvider
Definition
FuzzedDataProvider.h:32
FuzzedDataProvider::ConsumeBool
bool ConsumeBool()
Definition
FuzzedDataProvider.h:289
FuzzedDataProvider::ConsumeIntegralInRange
T ConsumeIntegralInRange(T min, T max)
Definition
FuzzedDataProvider.h:205
FuzzedDataProvider::ConsumeIntegral
T ConsumeIntegral()
Definition
FuzzedDataProvider.h:195
consensus.h
MAX_BLOCK_SIGOPS_COST
static const int64_t MAX_BLOCK_SIGOPS_COST
The maximum allowed number of signature check operations in a block (network rule)
Definition
consensus.h:17
mempool_entry.h
fee
uint64_t fee
Definition
mempool_ephemeral_spends.cpp:30
transaction.h
MakeTransactionRef
static CTransactionRef MakeTransactionRef(Tx &&txIn)
Definition
transaction.h:404
ConsumeTxMemPoolEntry
CTxMemPoolEntry ConsumeTxMemPoolEntry(FuzzedDataProvider &fuzzed_data_provider, const CTransaction &tx, uint32_t max_height) noexcept
Definition
mempool.cpp:17
mempool.h
ConsumeMoney
CAmount ConsumeMoney(FuzzedDataProvider &fuzzed_data_provider, const std::optional< CAmount > &max) noexcept
Definition
util.cpp:29
util.h
Ticks
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition
time.h:73
assert
assert(!tx.IsCoinBase())
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