mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge ae6943620a into merged_master (Bitcoin PR #17407)
This commit is contained in:
commit
fcc3e6c04c
11 changed files with 100 additions and 75 deletions
|
|
@ -18,16 +18,6 @@ bool CheckInputs(const CTransaction& tx, TxValidationState &state, const CCoinsV
|
|||
|
||||
BOOST_AUTO_TEST_SUITE(tx_validationcache_tests)
|
||||
|
||||
static bool
|
||||
ToMemPool(const CMutableTransaction& tx)
|
||||
{
|
||||
LOCK(cs_main);
|
||||
|
||||
TxValidationState state;
|
||||
return AcceptToMemoryPool(mempool, state, MakeTransactionRef(tx),
|
||||
nullptr /* plTxnReplaced */, true /* bypass_limits */, 0 /* nAbsurdFee */);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
|
||||
{
|
||||
// Make sure skipping validation of transactions that were
|
||||
|
|
@ -36,6 +26,14 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
|
|||
|
||||
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
|
||||
|
||||
const auto ToMemPool = [this](const CMutableTransaction& tx) {
|
||||
LOCK(cs_main);
|
||||
|
||||
TxValidationState state;
|
||||
return AcceptToMemoryPool(*m_node.mempool, state, MakeTransactionRef(tx),
|
||||
nullptr /* plTxnReplaced */, true /* bypass_limits */, 0 /* nAbsurdFee */);
|
||||
};
|
||||
|
||||
// Create a double-spend of mature coinbase txn:
|
||||
std::vector<CMutableTransaction> spends;
|
||||
spends.resize(2);
|
||||
|
|
@ -73,7 +71,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
|
|||
LOCK(cs_main);
|
||||
BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() != block.GetHash());
|
||||
}
|
||||
mempool.clear();
|
||||
m_node.mempool->clear();
|
||||
|
||||
// Test 3: ... and should be rejected if spend2 is in the memory pool
|
||||
BOOST_CHECK(ToMemPool(spends[1]));
|
||||
|
|
@ -82,9 +80,9 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
|
|||
LOCK(cs_main);
|
||||
BOOST_CHECK(::ChainActive().Tip()->GetBlockHash() != block.GetHash());
|
||||
}
|
||||
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 *m_node.mempool, second in block, that's OK:
|
||||
std::vector<CMutableTransaction> oneSpend;
|
||||
oneSpend.push_back(spends[0]);
|
||||
BOOST_CHECK(ToMemPool(spends[1]));
|
||||
|
|
@ -95,7 +93,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
|
|||
}
|
||||
// spends[1] should have been removed from the mempool when the
|
||||
// block with spends[0] is accepted:
|
||||
BOOST_CHECK_EQUAL(mempool.size(), 0U);
|
||||
BOOST_CHECK_EQUAL(m_node.mempool->size(), 0U);
|
||||
}
|
||||
|
||||
// Run CheckInputs (using CoinsTip()) on the given transaction, for all script
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue