Changeset View
Changeset View
Standalone View
Standalone View
src/test/txvalidation_tests.cpp
Show All 26 Lines | BOOST_FIXTURE_TEST_CASE(tx_mempool_reject_coinbase, TestChain100Setup) { | ||||
coinbaseTx.vin.resize(1); | coinbaseTx.vin.resize(1); | ||||
coinbaseTx.vout.resize(1); | coinbaseTx.vout.resize(1); | ||||
coinbaseTx.vin[0].scriptSig = CScript() << OP_11 << OP_EQUAL; | coinbaseTx.vin[0].scriptSig = CScript() << OP_11 << OP_EQUAL; | ||||
coinbaseTx.vout[0].nValue = 1 * CENT; | coinbaseTx.vout[0].nValue = 1 * CENT; | ||||
coinbaseTx.vout[0].scriptPubKey = scriptPubKey; | coinbaseTx.vout[0].scriptPubKey = scriptPubKey; | ||||
BOOST_CHECK(CTransaction(coinbaseTx).IsCoinBase()); | BOOST_CHECK(CTransaction(coinbaseTx).IsCoinBase()); | ||||
TxValidationState state; | |||||
LOCK(cs_main); | LOCK(cs_main); | ||||
unsigned int initialPoolSize = m_node.mempool->size(); | unsigned int initialPoolSize = m_node.mempool->size(); | ||||
const MempoolAcceptResult result = AcceptToMemoryPool( | |||||
m_node.chainman->ActiveChainstate(), GetConfig(), *m_node.mempool, | |||||
MakeTransactionRef(coinbaseTx), true /* bypass_limits */); | |||||
BOOST_CHECK_EQUAL(false, | BOOST_CHECK(result.m_result_type == | ||||
AcceptToMemoryPool(m_node.chainman->ActiveChainstate(), | MempoolAcceptResult::ResultType::INVALID); | ||||
GetConfig(), *m_node.mempool, state, | |||||
MakeTransactionRef(coinbaseTx), | |||||
true /* bypass_limits */)); | |||||
// Check that the transaction hasn't been added to mempool. | // Check that the transaction hasn't been added to mempool. | ||||
BOOST_CHECK_EQUAL(m_node.mempool->size(), initialPoolSize); | BOOST_CHECK_EQUAL(m_node.mempool->size(), initialPoolSize); | ||||
// Check that the validation state reflects the unsuccesful attempt. | // Check that the validation state reflects the unsuccesful attempt. | ||||
BOOST_CHECK(state.IsInvalid()); | BOOST_CHECK(result.m_state.IsInvalid()); | ||||
BOOST_CHECK_EQUAL(state.GetRejectReason(), "bad-tx-coinbase"); | BOOST_CHECK_EQUAL(result.m_state.GetRejectReason(), "bad-tx-coinbase"); | ||||
BOOST_CHECK(state.GetResult() == TxValidationResult::TX_CONSENSUS); | BOOST_CHECK(result.m_state.GetResult() == TxValidationResult::TX_CONSENSUS); | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |