13 #include <boost/test/unit_test.hpp>
23 tx.
vin.resize(inputs.size());
24 tx.
vout.resize(output_values.size());
25 for (
size_t i = 0; i < inputs.size(); ++i) {
26 tx.
vin[i].prevout.hash = inputs[i]->GetHash();
27 tx.
vin[i].prevout.n = 0;
30 witness.
stack.emplace_back(i + 10);
31 tx.
vin[i].scriptWitness = witness;
33 for (
size_t i = 0; i < output_values.size(); ++i) {
35 tx.
vout[i].nValue = output_values[i];
47 auto tx_to_spend = tx;
48 for (int32_t i{0}; i < num_descendants; ++i) {
49 auto next_tx =
make_tx({tx_to_spend}, {(50 - i) *
CENT});
50 pool.addUnchecked(entry.
FromTx(next_tx));
51 tx_to_spend = next_tx;
66 const auto tx1 =
make_tx( {m_coinbase_txns[0]}, {10 *
COIN});
72 const auto tx3 =
make_tx( {m_coinbase_txns[1]}, {1099 *
CENT});
78 const auto tx5 =
make_tx( {m_coinbase_txns[2]}, {1099 *
CENT});
87 const auto tx7 =
make_tx( {m_coinbase_txns[3]}, {999 *
CENT});
89 const auto tx8 =
make_tx( {m_coinbase_txns[4]}, {999 *
CENT});
92 const auto entry1 = pool.
GetIter(tx1->GetHash()).value();
93 const auto entry2 = pool.
GetIter(tx2->GetHash()).value();
94 const auto entry3 = pool.
GetIter(tx3->GetHash()).value();
95 const auto entry4 = pool.
GetIter(tx4->GetHash()).value();
96 const auto entry5 = pool.
GetIter(tx5->GetHash()).value();
97 const auto entry6 = pool.
GetIter(tx6->GetHash()).value();
98 const auto entry7 = pool.
GetIter(tx7->GetHash()).value();
99 const auto entry8 = pool.
GetIter(tx8->GetHash()).value();
121 CFeeRate(entry1->GetModifiedFee() + 1, entry1->GetTxSize() + 2),
122 unused_txid).has_value());
170 const std::vector<CTransactionRef> parent_inputs({m_coinbase_txns[0], m_coinbase_txns[1], m_coinbase_txns[2],
171 m_coinbase_txns[3], m_coinbase_txns[4]});
172 const auto conflicts_with_parents =
make_tx(parent_inputs, {50 *
CENT});
177 all_conflicts) == std::nullopt);
179 auto conflicts_size = all_conflicts.size();
180 all_conflicts.clear();
184 conflicts_size += 23;
186 all_conflicts.clear();
190 conflicts_size += 23;
192 all_conflicts.clear();
196 conflicts_size += 23;
198 all_conflicts.clear();
202 conflicts_size += 23;
205 all_conflicts.clear();
212 const auto spends_unconfirmed =
make_tx({tx1}, {36 *
CENT});
213 for (
const auto& input : spends_unconfirmed->vin) {
219 all_entries) == std::nullopt);
223 const auto spends_new_unconfirmed =
make_tx({tx1, tx8}, {36 *
CENT});
227 const auto spends_conflicting_confirmed =
make_tx({m_coinbase_txns[0], m_coinbase_txns[1]}, {45 *
CENT});
int64_t CAmount
Amount in satoshis (Can be negative)
static constexpr CAmount COIN
The amount of satoshis in one BTC.
#define Assert(val)
Identity function.
Fee rate in satoshis per kilovirtualbyte: CAmount / kvB.
Serialized script, used inside transaction inputs and outputs.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
void PrioritiseTransaction(const uint256 &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
std::optional< txiter > GetIter(const uint256 &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns an iterator to the given hash, if found.
std::set< txiter, CompareIteratorByHash > setEntries
bool exists(const GenTxid >xid) const
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void addUnchecked(const CTxMemPoolEntry &entry) EXCLUSIVE_LOCKS_REQUIRED(cs
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
static GenTxid Txid(const uint256 &hash)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
BOOST_AUTO_TEST_SUITE_END()
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
std::optional< std::string > PaysMoreThanConflicts(const CTxMemPool::setEntries &iters_conflicting, CFeeRate replacement_feerate, const uint256 &txid)
Check that the feerate of the replacement transaction(s) is higher than the feerate of each of the tr...
std::optional< std::string > HasNoNewUnconfirmed(const CTransaction &tx, const CTxMemPool &pool, const CTxMemPool::setEntries &iters_conflicting)
The replacement transaction may only include an unconfirmed input if that input was included in one o...
std::optional< std::string > PaysForRBF(CAmount original_fees, CAmount replacement_fees, size_t replacement_vsize, CFeeRate relay_fee, const uint256 &txid)
The replacement transaction must pay more fees than the original transactions.
std::optional< std::string > EntriesAndTxidsDisjoint(const CTxMemPool::setEntries &ancestors, const std::set< uint256 > &direct_conflicts, const uint256 &txid)
Check the intersection between two sets of transactions (a set of mempool entries and a set of txids)...
std::optional< std::string > GetEntriesForConflicts(const CTransaction &tx, CTxMemPool &pool, const CTxMemPool::setEntries &iters_conflicting, CTxMemPool::setEntries &all_conflicts)
Get all descendants of iters_conflicting.
static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE
Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or rep...
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
uint256 GetRandHash() noexcept
static CTransactionRef make_tx(const std::vector< CTransactionRef > &inputs, const std::vector< CAmount > &output_values)
static void add_descendants(const CTransactionRef &tx, int32_t num_descendants, CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(
BOOST_FIXTURE_TEST_CASE(rbf_helper_functions, TestChain100Setup)
static constexpr CAmount CENT
A mutable version of CTransaction.
std::vector< CTxOut > vout
std::vector< std::vector< unsigned char > > stack
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
TestMemPoolEntryHelper & Fee(CAmount _fee)
Testing setup that configures a complete environment.
std::unique_ptr< CTxMemPool > mempool
#define EXCLUSIVE_LOCKS_REQUIRED(...)