14#include <boost/test/unit_test.hpp>
61 txParent.
vin.resize(1);
63 txParent.
vout.resize(3);
64 for (
int i = 0; i < 3; i++)
67 txParent.
vout[i].nValue = 33000LL;
70 for (
int i = 0; i < 3; i++)
72 txChild[i].
vin.resize(1);
74 txChild[i].
vin[0].prevout.hash = txParent.
GetHash();
75 txChild[i].
vin[0].prevout.n = i;
76 txChild[i].
vout.resize(1);
78 txChild[i].
vout[0].nValue = 11000LL;
81 for (
int i = 0; i < 3; i++)
83 txGrandChild[i].
vin.resize(1);
85 txGrandChild[i].
vin[0].prevout.hash = txChild[i].
GetHash();
86 txGrandChild[i].
vin[0].prevout.n = 0;
87 txGrandChild[i].
vout.resize(1);
89 txGrandChild[i].
vout[0].nValue = 11000LL;
97 unsigned int poolSize = testPool.
size();
103 poolSize = testPool.
size();
109 for (
int i = 0; i < 3; i++)
115 poolSize = testPool.
size();
119 poolSize = testPool.
size();
122 poolSize = testPool.
size();
126 poolSize = testPool.
size();
132 for (
int i = 0; i < 3; i++)
139 poolSize = testPool.
size();
167 pool.TrimToSize(pool.DynamicMemoryUsage());
171 pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4);
185 pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4);
200 tx4.
vin[0].prevout.SetNull();
202 tx4.
vin[1].prevout.SetNull();
214 tx5.
vin[1].prevout.SetNull();
226 tx6.
vin[1].prevout.SetNull();
247 auto usage_with_tx4_only = pool.DynamicMemoryUsage();
256 pool.TrimToSize(pool.DynamicMemoryUsage() - 1);
263 if (!pool.exists(tx5.
GetHash()))
265 if (!pool.exists(tx6.
GetHash()))
270 pool.TrimToSize(usage_with_tx4_only + 1);
280 std::vector<CTransactionRef> vtx;
286 pool.removeForBlock(vtx, 1);
291 clock += HALFLIFE / 2;
295 clock += HALFLIFE / 4;
299 clock += 5 * HALFLIFE;
308inline CTransactionRef make_tx(std::vector<CAmount>&& output_values, std::vector<CTransactionRef>&& inputs=std::vector<CTransactionRef>(), std::vector<uint32_t>&& input_indices=std::vector<uint32_t>())
311 tx.
vin.resize(inputs.size());
312 tx.
vout.resize(output_values.size());
313 for (
size_t i = 0; i < inputs.size(); ++i) {
314 tx.
vin[i].prevout.hash = inputs[i]->GetHash();
315 tx.
vin[i].prevout.n = input_indices.size() > i ? input_indices[i] : 0;
317 for (
size_t i = 0; i < output_values.size(); ++i) {
319 tx.
vout[i].nValue = output_values[i];
327 size_t ancestors, clustersize;
427 for (uint64_t i = 0; i < 5; i++) {
429 tyi =
make_tx({v}, i > 0 ? std::vector<CTransactionRef>{*ty[i - 1]} : std::vector<CTransactionRef>{});
486 size_t ancestors, descendants;
int64_t CAmount
Amount in satoshis (Can be negative)
static constexpr CAmount COIN
The amount of satoshis in one BTC.
TryAddToMempool(pool, CTxMemPoolEntry(tx, fee, 0, 1, 0, false, 4, lp))
#define Assert(val)
Identity function.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
CAmount GetFeePerK() const
Return the fee in satoshis for a vsize of 1000 vbytes.
An outpoint - a combination of a transaction hash and an index n into its vout.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
CFeeRate GetMinFee() const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
void GetTransactionAncestry(const Txid &txid, size_t &ancestors, size_t &cluster_count, size_t *ancestorsize=nullptr, CAmount *ancestorfees=nullptr) const
Calculate the ancestor and cluster count for the given transaction.
static const int ROLLING_FEE_HALFLIFE
unsigned long size() const
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
BOOST_CHECK_EQUAL(headers.FindFirst("key"), "value")
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
CTransactionRef make_tx(std::vector< CAmount > &&output_values, std::vector< CTransactionRef > &&inputs=std::vector< CTransactionRef >(), std::vector< uint32_t > &&input_indices=std::vector< uint32_t >())
static constexpr auto REMOVAL_REASON_DUMMY
BOOST_AUTO_TEST_CASE(MempoolLookupTest)
#define BOOST_CHECK(expr)
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
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
static constexpr CAmount CENT
A mutable version of CTransaction.
std::vector< CTxOut > vout
Txid GetHash() const
Compute the hash of this CMutableTransaction.
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
TestMemPoolEntryHelper & Fee(CAmount _fee)
Testing setup that configures a complete environment.
std::unique_ptr< CTxMemPool > mempool