| 21 | * Ensure that the mempool won't accept coinbase transactions. |
| 22 | */ |
| 23 | BOOST_FIXTURE_TEST_CASE(tx_mempool_reject_coinbase, TestChain100Setup) |
| 24 | { |
| 25 | CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG; |
| 26 | CMutableTransaction coinbaseTx; |
| 27 | |
| 28 | coinbaseTx.nVersion = 1; |
| 29 | coinbaseTx.vin.resize(1); |
| 30 | coinbaseTx.vout.resize(1); |
| 31 | coinbaseTx.vin[0].scriptSig = CScript() << OP_11 << OP_EQUAL; |
| 32 | coinbaseTx.vout[0].nValue = 1 * CENT; |
| 33 | coinbaseTx.vout[0].scriptPubKey = scriptPubKey; |
| 34 | |
| 35 | BOOST_CHECK(CTransaction(coinbaseTx).IsCoinBase()); |
| 36 | |
| 37 | LOCK(cs_main); |
| 38 | |
| 39 | unsigned int initialPoolSize = m_node.mempool->size(); |
| 40 | const MempoolAcceptResult result = m_node.chainman->ProcessTransaction(MakeTransactionRef(coinbaseTx)); |
| 41 | |
| 42 | BOOST_CHECK(result.m_result_type == MempoolAcceptResult::ResultType::INVALID); |
| 43 | |
| 44 | // Check that the transaction hasn't been added to mempool. |
| 45 | BOOST_CHECK_EQUAL(m_node.mempool->size(), initialPoolSize); |
| 46 | |
| 47 | // Check that the validation state reflects the unsuccessful attempt. |
| 48 | BOOST_CHECK(result.m_state.IsInvalid()); |
| 49 | BOOST_CHECK_EQUAL(result.m_state.GetRejectReason(), "coinbase"); |
| 50 | BOOST_CHECK(result.m_state.GetResult() == TxValidationResult::TX_CONSENSUS); |
| 51 | } |
| 52 | BOOST_AUTO_TEST_SUITE_END() |
nothing calls this directly
no test coverage detected