Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
test
util
txmempool.h
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
#ifndef BITCOIN_TEST_UTIL_TXMEMPOOL_H
6
#define BITCOIN_TEST_UTIL_TXMEMPOOL_H
7
8
#include <
policy/packages.h
>
9
#include <
txmempool.h
>
10
#include <util/time.h>
11
12
namespace
node
{
13
struct
NodeContext
;
14
}
15
struct
PackageMempoolAcceptResult
;
16
17
CTxMemPool::Options
MemPoolOptionsForTest
(
const
node::NodeContext
&
node
);
18
19
struct
TestMemPoolEntryHelper
{
20
// Default values
21
CAmount
nFee
{0};
22
NodeSeconds
time
{};
23
unsigned
int
nHeight
{1};
24
uint64_t
m_sequence
{0};
25
bool
spendsCoinbase
{
false
};
26
unsigned
int
sigOpCost
{4};
27
LockPoints
lp
;
28
29
CTxMemPoolEntry
FromTx
(
const
CMutableTransaction
& tx)
const
;
30
CTxMemPoolEntry
FromTx
(
const
CTransactionRef
& tx)
const
;
31
32
// Change the default value
33
TestMemPoolEntryHelper
&
Fee
(
CAmount
_fee) {
nFee
= _fee;
return
*
this
; }
34
TestMemPoolEntryHelper
&
Time
(
NodeSeconds
tp) {
time
= tp;
return
*
this
; }
35
TestMemPoolEntryHelper
&
Height
(
unsigned
int
_height) {
nHeight
= _height;
return
*
this
; }
36
TestMemPoolEntryHelper
&
Sequence
(uint64_t _seq) {
m_sequence
= _seq;
return
*
this
; }
37
TestMemPoolEntryHelper
&
SpendsCoinbase
(
bool
_flag) {
spendsCoinbase
= _flag;
return
*
this
; }
38
TestMemPoolEntryHelper
&
SigOpsCost
(
unsigned
int
_sigopsCost) {
sigOpCost
= _sigopsCost;
return
*
this
; }
39
};
40
45
std::optional<std::string>
CheckPackageMempoolAcceptResult
(
const
Package
& txns,
46
const
PackageMempoolAcceptResult
& result,
47
bool
expect_valid,
48
const
CTxMemPool
* mempool);
49
55
void
CheckMempoolEphemeralInvariants
(
const
CTxMemPool
& tx_pool);
56
64
void
CheckMempoolTRUCInvariants
(
const
CTxMemPool
& tx_pool);
65
68
void
TryAddToMempool
(
CTxMemPool
& tx_pool,
const
CTxMemPoolEntry
& entry);
69
81
void
MockMempoolMinFee
(
const
CFeeRate
& target_feerate,
CTxMemPool
& mempool);
82
83
#endif
// BITCOIN_TEST_UTIL_TXMEMPOOL_H
CAmount
int64_t CAmount
Amount in satoshis (Can be negative).
Definition
amount.h:12
CFeeRate
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
Definition
feerate.h:32
CTxMemPoolEntry
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
Definition
mempool_entry.h:66
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition
txmempool.h:187
CTxMemPool::Options
kernel::MemPoolOptions Options
Definition
txmempool.h:299
node
Definition
messages.h:21
packages.h
Package
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
Definition
packages.h:45
CTransactionRef
std::shared_ptr< const CTransaction > CTransactionRef
Definition
transaction.h:403
CMutableTransaction
A mutable version of CTransaction.
Definition
transaction.h:358
LockPoints
Definition
mempool_entry.h:26
PackageMempoolAcceptResult
Validation result for package mempool acceptance.
Definition
validation.h:237
TestMemPoolEntryHelper
Definition
txmempool.h:19
TestMemPoolEntryHelper::SigOpsCost
TestMemPoolEntryHelper & SigOpsCost(unsigned int _sigopsCost)
Definition
txmempool.h:38
TestMemPoolEntryHelper::Time
TestMemPoolEntryHelper & Time(NodeSeconds tp)
Definition
txmempool.h:34
TestMemPoolEntryHelper::nFee
CAmount nFee
Definition
txmempool.h:21
TestMemPoolEntryHelper::spendsCoinbase
bool spendsCoinbase
Definition
txmempool.h:25
TestMemPoolEntryHelper::lp
LockPoints lp
Definition
txmempool.h:27
TestMemPoolEntryHelper::FromTx
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
Definition
txmempool.cpp:34
TestMemPoolEntryHelper::SpendsCoinbase
TestMemPoolEntryHelper & SpendsCoinbase(bool _flag)
Definition
txmempool.h:37
TestMemPoolEntryHelper::nHeight
unsigned int nHeight
Definition
txmempool.h:23
TestMemPoolEntryHelper::sigOpCost
unsigned int sigOpCost
Definition
txmempool.h:26
TestMemPoolEntryHelper::Height
TestMemPoolEntryHelper & Height(unsigned int _height)
Definition
txmempool.h:35
TestMemPoolEntryHelper::Fee
TestMemPoolEntryHelper & Fee(CAmount _fee)
Definition
txmempool.h:33
TestMemPoolEntryHelper::time
NodeSeconds time
Definition
txmempool.h:22
TestMemPoolEntryHelper::m_sequence
uint64_t m_sequence
Definition
txmempool.h:24
TestMemPoolEntryHelper::Sequence
TestMemPoolEntryHelper & Sequence(uint64_t _seq)
Definition
txmempool.h:36
node::NodeContext
Definition
context.h:56
txmempool.h
MemPoolOptionsForTest
CTxMemPool::Options MemPoolOptionsForTest(const node::NodeContext &node)
Definition
txmempool.cpp:21
CheckMempoolTRUCInvariants
void CheckMempoolTRUCInvariants(const CTxMemPool &tx_pool)
For every transaction in tx_pool, check TRUC invariants:
Definition
txmempool.cpp:182
CheckPackageMempoolAcceptResult
std::optional< std::string > CheckPackageMempoolAcceptResult(const Package &txns, const PackageMempoolAcceptResult &result, bool expect_valid, const CTxMemPool *mempool)
Check expected properties for every PackageMempoolAcceptResult, regardless of value.
Definition
txmempool.cpp:44
CheckMempoolEphemeralInvariants
void CheckMempoolEphemeralInvariants(const CTxMemPool &tx_pool)
Check that we never get into a state where an ephemeral dust transaction would be mined without the s...
Definition
txmempool.cpp:145
TryAddToMempool
void TryAddToMempool(CTxMemPool &tx_pool, const CTxMemPoolEntry &entry)
One-line wrapper for creating a mempool changeset with a single transaction and applying it if the po...
Definition
txmempool.cpp:215
MockMempoolMinFee
void MockMempoolMinFee(const CFeeRate &target_feerate, CTxMemPool &mempool)
Mock the mempool minimum feerate by adding a transaction and calling TrimToSize(0),...
Definition
txmempool.cpp:225
NodeSeconds
std::chrono::time_point< NodeClock, std::chrono::seconds > NodeSeconds
Definition
time.h:25
Generated on
for Bitcoin Core by
1.17.0