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