13 #include <boost/test/unit_test.hpp> 34 txParent.
vin.resize(1);
36 txParent.
vout.resize(3);
37 for (
int i = 0; i < 3; i++)
40 txParent.
vout[i].nValue = 33000LL;
43 for (
int i = 0; i < 3; i++)
45 txChild[i].
vin.resize(1);
47 txChild[i].
vin[0].prevout.hash = txParent.
GetHash();
48 txChild[i].
vin[0].prevout.n = i;
49 txChild[i].
vout.resize(1);
51 txChild[i].
vout[0].nValue = 11000LL;
54 for (
int i = 0; i < 3; i++)
56 txGrandChild[i].
vin.resize(1);
58 txGrandChild[i].
vin[0].prevout.hash = txChild[i].
GetHash();
59 txGrandChild[i].
vin[0].prevout.n = 0;
60 txGrandChild[i].
vout.resize(1);
62 txGrandChild[i].
vout[0].nValue = 11000LL;
70 unsigned int poolSize = testPool.
size();
76 poolSize = testPool.
size();
82 for (
int i = 0; i < 3; i++)
88 poolSize = testPool.
size();
92 poolSize = testPool.
size();
95 poolSize = testPool.
size();
99 poolSize = testPool.
size();
105 for (
int i = 0; i < 3; i++)
112 poolSize = testPool.
size();
137 tx2.vout[0].nValue = 10 *
COIN;
140 pool.TrimToSize(pool.DynamicMemoryUsage());
144 pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4);
151 tx3.vin[0].prevout =
COutPoint(tx2.GetHash(), 0);
155 tx3.vout[0].nValue = 10 *
COIN;
158 pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4);
173 tx4.vin[0].prevout.SetNull();
175 tx4.vin[1].prevout.SetNull();
179 tx4.vout[0].nValue = 10 *
COIN;
181 tx4.vout[1].nValue = 10 *
COIN;
187 tx5.
vin[1].prevout.SetNull();
199 tx6.
vin[1].prevout.SetNull();
220 auto usage_with_tx4_only = pool.DynamicMemoryUsage();
229 pool.TrimToSize(pool.DynamicMemoryUsage() - 1);
236 if (!pool.exists(tx5.
GetHash()))
238 if (!pool.exists(tx6.
GetHash()))
243 pool.TrimToSize(usage_with_tx4_only + 1);
253 std::vector<CTransactionRef> vtx;
258 pool.removeForBlock(vtx, 1);
280 inline 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>())
283 tx.
vin.resize(inputs.size());
284 tx.
vout.resize(output_values.size());
285 for (
size_t i = 0; i < inputs.size(); ++i) {
286 tx.
vin[i].prevout.hash = inputs[i]->GetHash();
287 tx.
vin[i].prevout.n = input_indices.size() > i ? input_indices[i] : 0;
289 for (
size_t i = 0; i < output_values.size(); ++i) {
291 tx.
vout[i].nValue = output_values[i];
299 size_t ancestors, clustersize;
399 for (uint64_t i = 0; i < 5; i++) {
401 tyi =
make_tx({v}, i > 0 ? std::vector<CTransactionRef>{*ty[i - 1]} : std::vector<CTransactionRef>{});
458 size_t ancestors, descendants;
std::shared_ptr< const CTransaction > CTransactionRef
static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE
Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or rep...
TestMemPoolEntryHelper & Fee(CAmount _fee)
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal...
unsigned long size() const
TryAddToMempool(pool, CTxMemPoolEntry(tx, fee, 0, 1, 0, false, 4, lp))
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
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...
CFeeRate GetMinFee() const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
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 >())
std::unique_ptr< CTxMemPool > mempool
int64_t CAmount
Amount in satoshis (Can be negative)
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
static constexpr auto REMOVAL_REASON_DUMMY
BOOST_AUTO_TEST_SUITE_END()
static const int ROLLING_FEE_HALFLIFE
Txid GetHash() const
Compute the hash of this CMutableTransaction.
An outpoint - a combination of a transaction hash and an index n into its vout.
std::vector< CTxOut > vout
static CTransactionRef MakeTransactionRef(Tx &&txIn)
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
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.
#define BOOST_CHECK_EQUAL(v1, v2)
Serialized script, used inside transaction inputs and outputs.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac...
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
A mutable version of CTransaction.
static constexpr CAmount CENT
BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
The basic transaction that is broadcasted on the network and contained in blocks. ...
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
CAmount GetFeePerK() const
Return the fee in satoshis for a vsize of 1000 vbytes.
Testing setup that configures a complete environment.
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it...
#define Assert(val)
Identity function.
#define BOOST_CHECK(expr)
static constexpr CAmount COIN
The amount of satoshis in one BTC.