Changeset View
Changeset View
Standalone View
Standalone View
src/test/mempool_tests.cpp
Show First 20 Lines • Show All 869 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(TestImportMempool) { | ||||
// Now we test all combinations of the previously defined orders for | // Now we test all combinations of the previously defined orders for | ||||
// disconnected and unconfirmed txns. The expected outcome is to have these | // disconnected and unconfirmed txns. The expected outcome is to have these | ||||
// transactions in the correct order in queuedTx, as defined in | // transactions in the correct order in queuedTx, as defined in | ||||
// correctlyOrderedIds. | // correctlyOrderedIds. | ||||
for (auto &disconnectedTxns : | for (auto &disconnectedTxns : | ||||
{disconnectedTxnsInOrder, disconnectedTxnsMixedOrder, | {disconnectedTxnsInOrder, disconnectedTxnsMixedOrder, | ||||
disconnectedTxnsInvertedOrder}) { | disconnectedTxnsInvertedOrder}) { | ||||
for (auto &unconfTxns : {unconfTxnsInOrder, unconfTxnsOutOfOrder}) { | for (auto &unconfTxns : {unconfTxnsInOrder, unconfTxnsOutOfOrder}) { | ||||
CTxMemPool testPool; | |||||
// addForBlock inserts disconnectTxns in disconnectPool. They | // addForBlock inserts disconnectTxns in disconnectPool. They | ||||
// simulate transactions that were once confirmed in a block | // simulate transactions that were once confirmed in a block | ||||
std::vector<CTransactionRef> vtx; | std::vector<CTransactionRef> vtx; | ||||
for (auto tx : disconnectedTxns) { | for (auto tx : disconnectedTxns) { | ||||
vtx.push_back(MakeTransactionRef(*tx)); | vtx.push_back(MakeTransactionRef(*tx)); | ||||
} | } | ||||
DisconnectedBlockTransactions disconnectPool; | DisconnectedBlockTransactions disconnectPool; | ||||
disconnectPool.addForBlock(vtx); | disconnectPool.addForBlock(vtx, testPool); | ||||
CheckDisconnectPoolOrder(disconnectPool, correctlyOrderedIds, | CheckDisconnectPoolOrder(disconnectPool, correctlyOrderedIds, | ||||
disconnectedTxns.size()); | disconnectedTxns.size()); | ||||
// If the mempool is empty, importMempool doesn't change | // If the mempool is empty, importMempool doesn't change | ||||
// disconnectPool | // disconnectPool | ||||
CTxMemPool testPool; | |||||
disconnectPool.importMempool(testPool); | disconnectPool.importMempool(testPool); | ||||
CheckDisconnectPoolOrder(disconnectPool, correctlyOrderedIds, | CheckDisconnectPoolOrder(disconnectPool, correctlyOrderedIds, | ||||
disconnectedTxns.size()); | disconnectedTxns.size()); | ||||
{ | { | ||||
LOCK2(cs_main, testPool.cs); | LOCK2(cs_main, testPool.cs); | ||||
// Add all unconfirmed transactions in testPool | // Add all unconfirmed transactions in testPool | ||||
for (auto tx : unconfTxns) { | for (auto tx : unconfTxns) { | ||||
▲ Show 20 Lines • Show All 241 Lines • Show Last 20 Lines |