Bitcoin Core 30.99.0
P2P Digital Currency
Functions
txmempool.cpp File Reference
#include <test/util/txmempool.h>
#include <chainparams.h>
#include <node/context.h>
#include <node/mempool_args.h>
#include <policy/rbf.h>
#include <policy/truc_policy.h>
#include <test/util/transaction_utils.h>
#include <util/check.h>
#include <util/time.h>
#include <util/translation.h>
#include <validation.h>
Include dependency graph for txmempool.cpp:

Go to the source code of this file.

Functions

CTxMemPool::Options MemPoolOptionsForTest (const NodeContext &node)
 
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. More...
 
void CheckMempoolEphemeralInvariants (const CTxMemPool &tx_pool)
 Check that we never get into a state where an ephemeral dust transaction would be mined without the spend of the dust also being mined. More...
 
void CheckMempoolTRUCInvariants (const CTxMemPool &tx_pool)
 For every transaction in tx_pool, check TRUC invariants: More...
 
void AddToMempool (CTxMemPool &tx_pool, const CTxMemPoolEntry &entry)
 One-line wrapper for creating a mempool changeset with a single transaction and applying it. More...
 
void MockMempoolMinFee (const CFeeRate &target_feerate, CTxMemPool &mempool)
 Mock the mempool minimum feerate by adding a transaction and calling TrimToSize(0), simulating the mempool "reaching capacity" and evicting by descendant feerate. More...
 

Function Documentation

◆ AddToMempool()

void AddToMempool ( CTxMemPool tx_pool,
const CTxMemPoolEntry entry 
)

One-line wrapper for creating a mempool changeset with a single transaction and applying it.

Definition at line 213 of file txmempool.cpp.

Here is the call graph for this function:

◆ 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 spend of the dust also being mined.

This assumes standardness checks are being enforced.

Definition at line 145 of file txmempool.cpp.

Here is the call graph for this function:

◆ CheckMempoolTRUCInvariants()

void CheckMempoolTRUCInvariants ( const CTxMemPool tx_pool)

For every transaction in tx_pool, check TRUC invariants:

  • a TRUC tx's ancestor count must be within TRUC_ANCESTOR_LIMIT
  • a TRUC tx's descendant count must be within TRUC_DESCENDANT_LIMIT
  • if a TRUC tx has ancestors, its sigop-adjusted vsize must be within TRUC_CHILD_MAX_VSIZE
  • any non-TRUC tx must only have non-TRUC parents
  • any TRUC tx must only have TRUC parents

Definition at line 182 of file txmempool.cpp.

Here is the call graph for this function:

◆ 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.

Returns a string if an error occurs with error populated, nullopt otherwise. If mempool is provided, checks that the expected transactions are in mempool (this should be set to nullptr for a test_accept).

Definition at line 44 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MemPoolOptionsForTest()

CTxMemPool::Options MemPoolOptionsForTest ( const NodeContext node)

Definition at line 21 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MockMempoolMinFee()

void MockMempoolMinFee ( const CFeeRate target_feerate,
CTxMemPool mempool 
)

Mock the mempool minimum feerate by adding a transaction and calling TrimToSize(0), simulating the mempool "reaching capacity" and evicting by descendant feerate.

Note that this clears the mempool, and the new minimum feerate will depend on the maximum feerate of transactions removed, so this must be called while the mempool is empty.

Parameters
target_feerateThe new mempool minimum feerate after this function returns. Must be above max(incremental feerate, min relay feerate), or 1sat/vB with default settings.
mempoolThe mempool to mock the minimum feerate for. Must be empty when called.

Definition at line 223 of file txmempool.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: