Changeset View
Changeset View
Standalone View
Standalone View
src/test/mempool_tests.cpp
Show First 20 Lines • Show All 42 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.hash = txChild[i].GetId(); | txGrandChild[i].vin[0].prevout.hash = txChild[i].GetId(); | ||||
txGrandChild[i].vin[0].prevout.n = 0; | txGrandChild[i].vin[0].prevout.n = 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 = Amount(11000LL); | txGrandChild[i].vout[0].nValue = Amount(11000LL); | ||||
} | } | ||||
CTxMemPool testPool(CFeeRate(Amount(0))); | CTxMemPool testPool; | ||||
// 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 50 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(MempoolClearTest) { | ||||
txParent.vin.resize(1); | txParent.vin.resize(1); | ||||
txParent.vin[0].scriptSig = CScript() << OP_11; | txParent.vin[0].scriptSig = CScript() << OP_11; | ||||
txParent.vout.resize(3); | txParent.vout.resize(3); | ||||
for (int i = 0; i < 3; i++) { | for (int i = 0; i < 3; i++) { | ||||
txParent.vout[i].scriptPubKey = CScript() << OP_11 << OP_EQUAL; | txParent.vout[i].scriptPubKey = CScript() << OP_11 << OP_EQUAL; | ||||
txParent.vout[i].nValue = Amount(33000LL); | txParent.vout[i].nValue = Amount(33000LL); | ||||
} | } | ||||
CTxMemPool testPool(CFeeRate(Amount(0))); | CTxMemPool testPool; | ||||
// Nothing in pool, clear should do nothing: | // Nothing in pool, clear should do nothing: | ||||
testPool.clear(); | testPool.clear(); | ||||
BOOST_CHECK_EQUAL(testPool.size(), 0UL); | BOOST_CHECK_EQUAL(testPool.size(), 0UL); | ||||
// Add the transaction | // Add the transaction | ||||
testPool.addUnchecked(txParent.GetId(), entry.FromTx(txParent)); | testPool.addUnchecked(txParent.GetId(), entry.FromTx(txParent)); | ||||
BOOST_CHECK_EQUAL(testPool.size(), 1UL); | BOOST_CHECK_EQUAL(testPool.size(), 1UL); | ||||
Show All 16 Lines | typename CTxMemPool::indexed_transaction_set::index<name>::type::iterator | ||||
it = pool.mapTx.get<name>().begin(); | it = pool.mapTx.get<name>().begin(); | ||||
int count = 0; | int count = 0; | ||||
for (; it != pool.mapTx.get<name>().end(); ++it, ++count) { | for (; it != pool.mapTx.get<name>().end(); ++it, ++count) { | ||||
BOOST_CHECK_EQUAL(it->GetTx().GetId().ToString(), sortedOrder[count]); | BOOST_CHECK_EQUAL(it->GetTx().GetId().ToString(), sortedOrder[count]); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(MempoolIndexingTest) { | BOOST_AUTO_TEST_CASE(MempoolIndexingTest) { | ||||
CTxMemPool pool(CFeeRate(Amount(0))); | CTxMemPool pool; | ||||
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 200 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(MempoolIndexingTest) { | ||||
} else { | } else { | ||||
sortedOrder.push_back(tx3.GetId().ToString()); | sortedOrder.push_back(tx3.GetId().ToString()); | ||||
sortedOrder.push_back(tx6.GetId().ToString()); | sortedOrder.push_back(tx6.GetId().ToString()); | ||||
} | } | ||||
CheckSort<mining_score>(pool, sortedOrder); | CheckSort<mining_score>(pool, sortedOrder); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest) { | BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest) { | ||||
CTxMemPool pool(CFeeRate(Amount(0))); | CTxMemPool pool; | ||||
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 98 Lines • ▼ Show 20 Lines | if (tx3.GetId() < tx6.GetId()) | ||||
sortedOrder.pop_back(); | sortedOrder.pop_back(); | ||||
else | else | ||||
sortedOrder.erase(sortedOrder.end() - 2); | sortedOrder.erase(sortedOrder.end() - 2); | ||||
sortedOrder.insert(sortedOrder.begin(), tx7.GetId().ToString()); | sortedOrder.insert(sortedOrder.begin(), tx7.GetId().ToString()); | ||||
CheckSort<ancestor_score>(pool, sortedOrder); | CheckSort<ancestor_score>(pool, sortedOrder); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest) { | BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest) { | ||||
CTxMemPool pool(CFeeRate(Amount(1000))); | CTxMemPool pool; | ||||
TestMemPoolEntryHelper entry; | TestMemPoolEntryHelper entry; | ||||
entry.dPriority = 10.0; | entry.dPriority = 10.0; | ||||
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); | ||||
tx1.vout[0].scriptPubKey = CScript() << OP_1 << OP_EQUAL; | tx1.vout[0].scriptPubKey = CScript() << OP_1 << OP_EQUAL; | ||||
▲ Show 20 Lines • Show All 177 Lines • Show Last 20 Lines |