Changeset View
Changeset View
Standalone View
Standalone View
src/test/mempool_tests.cpp
Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | for (int i = 0; i < 3; i++) { | ||||
txGrandChild[i].vin[0].scriptSig = CScript() << OP_11; | txGrandChild[i].vin[0].scriptSig = CScript() << OP_11; | ||||
txGrandChild[i].vin[0].prevout = COutPoint(txChild[i].GetId(), 0); | txGrandChild[i].vin[0].prevout = COutPoint(txChild[i].GetId(), 0); | ||||
txGrandChild[i].vout.resize(1); | txGrandChild[i].vout.resize(1); | ||||
txGrandChild[i].vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; | txGrandChild[i].vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; | ||||
txGrandChild[i].vout[0].nValue = 11000 * SATOSHI; | txGrandChild[i].vout[0].nValue = 11000 * SATOSHI; | ||||
} | } | ||||
CTxMemPool testPool; | CTxMemPool testPool; | ||||
LOCK(testPool.cs); | LOCK2(cs_main, testPool.cs); | ||||
// Nothing in pool, remove should do nothing: | // Nothing in pool, remove should do nothing: | ||||
unsigned int poolSize = testPool.size(); | unsigned int poolSize = testPool.size(); | ||||
testPool.removeRecursive(CTransaction(txParent)); | testPool.removeRecursive(CTransaction(txParent)); | ||||
BOOST_CHECK_EQUAL(testPool.size(), poolSize); | BOOST_CHECK_EQUAL(testPool.size(), poolSize); | ||||
// Just the parent: | // Just the parent: | ||||
testPool.addUnchecked(txParent.GetId(), entry.FromTx(txParent)); | testPool.addUnchecked(txParent.GetId(), entry.FromTx(txParent)); | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | for (; it != pool.mapTx.get<name>().end(); ++it, ++count) { | ||||
it->GetTx().GetId().ToString() | it->GetTx().GetId().ToString() | ||||
<< " != " << sortedOrder[count] << " in test " | << " != " << sortedOrder[count] << " in test " | ||||
<< testcase << ":" << count); | << testcase << ":" << count); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(MempoolIndexingTest) { | BOOST_AUTO_TEST_CASE(MempoolIndexingTest) { | ||||
CTxMemPool pool; | CTxMemPool pool; | ||||
LOCK(pool.cs); | LOCK2(cs_main, pool.cs); | ||||
TestMemPoolEntryHelper entry; | TestMemPoolEntryHelper entry; | ||||
/* 3rd highest fee */ | /* 3rd highest fee */ | ||||
CMutableTransaction tx1 = CMutableTransaction(); | CMutableTransaction tx1 = CMutableTransaction(); | ||||
tx1.vout.resize(1); | tx1.vout.resize(1); | ||||
tx1.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; | tx1.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; | ||||
tx1.vout[0].nValue = 10 * COIN; | tx1.vout[0].nValue = 10 * COIN; | ||||
pool.addUnchecked(tx1.GetId(), | pool.addUnchecked(tx1.GetId(), | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(MempoolIndexingTest) { | ||||
CheckSort<descendant_score>(pool, snapshotOrder, "MempoolIndexingTest7"); | CheckSort<descendant_score>(pool, snapshotOrder, "MempoolIndexingTest7"); | ||||
pool.removeRecursive(pool.mapTx.find(tx9.GetId())->GetTx()); | pool.removeRecursive(pool.mapTx.find(tx9.GetId())->GetTx()); | ||||
pool.removeRecursive(pool.mapTx.find(tx8.GetId())->GetTx()); | pool.removeRecursive(pool.mapTx.find(tx8.GetId())->GetTx()); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest) { | BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest) { | ||||
CTxMemPool pool; | CTxMemPool pool; | ||||
LOCK(pool.cs); | LOCK2(cs_main, pool.cs); | ||||
TestMemPoolEntryHelper entry; | TestMemPoolEntryHelper entry; | ||||
/* 3rd highest fee */ | /* 3rd highest fee */ | ||||
CMutableTransaction tx1 = CMutableTransaction(); | CMutableTransaction tx1 = CMutableTransaction(); | ||||
tx1.vout.resize(1); | tx1.vout.resize(1); | ||||
tx1.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; | tx1.vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; | ||||
tx1.vout[0].nValue = 10 * COIN; | tx1.vout[0].nValue = 10 * COIN; | ||||
pool.addUnchecked(tx1.GetId(), | pool.addUnchecked(tx1.GetId(), | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | pool.addUnchecked(tx8.GetId(), | ||||
entry.Fee(Amount(5000 * SATOSHI)).FromTx(tx8)); | entry.Fee(Amount(5000 * SATOSHI)).FromTx(tx8)); | ||||
sortedOrder.insert(sortedOrder.end() - 1, tx8.GetId().ToString()); | sortedOrder.insert(sortedOrder.end() - 1, tx8.GetId().ToString()); | ||||
CheckSort<ancestor_score>(pool, sortedOrder, | CheckSort<ancestor_score>(pool, sortedOrder, | ||||
"MempoolAncestorIndexingTest5"); | "MempoolAncestorIndexingTest5"); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest) { | BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest) { | ||||
CTxMemPool pool; | CTxMemPool pool; | ||||
LOCK(pool.cs); | LOCK2(cs_main, pool.cs); | ||||
TestMemPoolEntryHelper entry; | TestMemPoolEntryHelper entry; | ||||
entry.dPriority = 10.0; | entry.dPriority = 10.0; | ||||
Amount feeIncrement = MEMPOOL_FULL_FEE_INCREMENT.GetFeePerK(); | Amount feeIncrement = MEMPOOL_FULL_FEE_INCREMENT.GetFeePerK(); | ||||
CMutableTransaction tx1 = CMutableTransaction(); | CMutableTransaction tx1 = CMutableTransaction(); | ||||
tx1.vin.resize(1); | tx1.vin.resize(1); | ||||
tx1.vin[0].scriptSig = CScript() << OP_1; | tx1.vin[0].scriptSig = CScript() << OP_1; | ||||
tx1.vout.resize(1); | tx1.vout.resize(1); | ||||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | #define MK_INPUTS(txs...) \ | ||||
std::vector<CTransactionRef> { txs } | std::vector<CTransactionRef> { txs } | ||||
#define MK_INPUT_IDX(idxes...) \ | #define MK_INPUT_IDX(idxes...) \ | ||||
std::vector<uint32_t> { idxes } | std::vector<uint32_t> { idxes } | ||||
BOOST_AUTO_TEST_CASE(MempoolAncestryTests) { | BOOST_AUTO_TEST_CASE(MempoolAncestryTests) { | ||||
size_t ancestors, descendants; | size_t ancestors, descendants; | ||||
CTxMemPool pool; | CTxMemPool pool; | ||||
LOCK(pool.cs); | LOCK2(cs_main, pool.cs); | ||||
TestMemPoolEntryHelper entry; | TestMemPoolEntryHelper entry; | ||||
/* Base transaction */ | /* Base transaction */ | ||||
// | // | ||||
// [tx1] | // [tx1] | ||||
// | // | ||||
CTransactionRef tx1 = make_tx(MK_OUTPUTS(10 * COIN)); | CTransactionRef tx1 = make_tx(MK_OUTPUTS(10 * COIN)); | ||||
pool.addUnchecked(tx1->GetId(), entry.Fee(10000 * SATOSHI).FromTx(tx1)); | pool.addUnchecked(tx1->GetId(), entry.Fee(10000 * SATOSHI).FromTx(tx1)); | ||||
▲ Show 20 Lines • Show All 150 Lines • Show Last 20 Lines |