Changeset View
Changeset View
Standalone View
Standalone View
src/test/txvalidationcache_tests.cpp
Show All 26 Lines | BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup) { | ||||
// into the memory pool does not allow double-spends in blocks to pass | // into the memory pool does not allow double-spends in blocks to pass | ||||
// validation when they should not. | // validation when they should not. | ||||
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) | CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) | ||||
<< OP_CHECKSIG; | << OP_CHECKSIG; | ||||
const auto ToMemPool = [this](const CMutableTransaction &tx) { | const auto ToMemPool = [this](const CMutableTransaction &tx) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
TxValidationState state; | const MempoolAcceptResult result = AcceptToMemoryPool( | ||||
return AcceptToMemoryPool( | |||||
m_node.chainman->ActiveChainstate(), GetConfig(), *m_node.mempool, | m_node.chainman->ActiveChainstate(), GetConfig(), *m_node.mempool, | ||||
state, MakeTransactionRef(tx), true /* bypass_limits */); | MakeTransactionRef(tx), true /* bypass_limits */); | ||||
return result.m_result_type == MempoolAcceptResult::ResultType::VALID; | |||||
}; | }; | ||||
// Create a double-spend of mature coinbase txn: | // Create a double-spend of mature coinbase txn: | ||||
std::vector<CMutableTransaction> spends; | std::vector<CMutableTransaction> spends; | ||||
spends.resize(2); | spends.resize(2); | ||||
for (int i = 0; i < 2; i++) { | for (int i = 0; i < 2; i++) { | ||||
spends[i].nVersion = 1; | spends[i].nVersion = 1; | ||||
spends[i].vin.resize(1); | spends[i].vin.resize(1); | ||||
▲ Show 20 Lines • Show All 648 Lines • Show Last 20 Lines |