MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / BOOST_FIXTURE_TEST_CASE

Function BOOST_FIXTURE_TEST_CASE

src/test/txvalidation_tests.cpp:27–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 * Ensure that the mempool won't accept coinbase transactions.
26 */
27BOOST_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.
58static inline std::vector<COutPoint> random_outpoints(size_t num_outpoints) {

Callers

nothing calls this directly

Calls 15

ToByteVectorFunction · 0.85
MakeTransactionRefFunction · 0.85
make_ephemeral_txFunction · 0.85
random_outpointsFunction · 0.85
CheckEphemeralSpendsFunction · 0.85
TryAddToMempoolFunction · 0.85
SingleTRUCChecksFunction · 0.85
PackageTRUCChecksFunction · 0.85
random_keysFunction · 0.85
GetTransactionWeightFunction · 0.85
ProcessTransactionMethod · 0.80
IsInvalidMethod · 0.80

Tested by

no test coverage detected