Changeset View
Changeset View
Standalone View
Standalone View
src/test/txvalidationcache_tests.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup) { | ||||
// Test 2: ... and should be rejected if spend1 is in the memory pool | // Test 2: ... and should be rejected if spend1 is in the memory pool | ||||
BOOST_CHECK(ToMemPool(spends[0])); | BOOST_CHECK(ToMemPool(spends[0])); | ||||
block = CreateAndProcessBlock(spends, scriptPubKey); | block = CreateAndProcessBlock(spends, scriptPubKey); | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() != block.GetHash()); | BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() != block.GetHash()); | ||||
} | } | ||||
g_mempool.clear(); | m_node.mempool->clear(); | ||||
// Test 3: ... and should be rejected if spend2 is in the memory pool | // Test 3: ... and should be rejected if spend2 is in the memory pool | ||||
BOOST_CHECK(ToMemPool(spends[1])); | BOOST_CHECK(ToMemPool(spends[1])); | ||||
block = CreateAndProcessBlock(spends, scriptPubKey); | block = CreateAndProcessBlock(spends, scriptPubKey); | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() != block.GetHash()); | BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() != block.GetHash()); | ||||
} | } | ||||
g_mempool.clear(); | m_node.mempool->clear(); | ||||
// Final sanity test: first spend in mempool, second in block, that's OK: | // Final sanity test: first spend in mempool, second in block, that's OK: | ||||
std::vector<CMutableTransaction> oneSpend; | std::vector<CMutableTransaction> oneSpend; | ||||
oneSpend.push_back(spends[0]); | oneSpend.push_back(spends[0]); | ||||
BOOST_CHECK(ToMemPool(spends[1])); | BOOST_CHECK(ToMemPool(spends[1])); | ||||
block = CreateAndProcessBlock(oneSpend, scriptPubKey); | block = CreateAndProcessBlock(oneSpend, scriptPubKey); | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() == block.GetHash()); | BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() == block.GetHash()); | ||||
} | } | ||||
// spends[1] should have been removed from the mempool when the block with | // spends[1] should have been removed from the mempool when the block with | ||||
// spends[0] is accepted: | // spends[0] is accepted: | ||||
BOOST_CHECK_EQUAL(g_mempool.size(), 0U); | BOOST_CHECK_EQUAL(m_node.mempool->size(), 0U); | ||||
} | } | ||||
static inline bool | static inline bool | ||||
CheckInputs(const CTransaction &tx, CValidationState &state, | CheckInputs(const CTransaction &tx, CValidationState &state, | ||||
const CCoinsViewCache &view, bool fScriptChecks, | const CCoinsViewCache &view, bool fScriptChecks, | ||||
const uint32_t flags, bool sigCacheStore, bool scriptCacheStore, | const uint32_t flags, bool sigCacheStore, bool scriptCacheStore, | ||||
const PrecomputedTransactionData &txdata, int &nSigChecksOut, | const PrecomputedTransactionData &txdata, int &nSigChecksOut, | ||||
std::vector<CScriptCheck> *pvChecks, | std::vector<CScriptCheck> *pvChecks, | ||||
▲ Show 20 Lines • Show All 558 Lines • Show Last 20 Lines |