MCPcopy Create free account
hub / github.com/ElementsProject/elements / BOOST_FIXTURE_TEST_CASE

Function BOOST_FIXTURE_TEST_CASE

src/test/txvalidation_tests.cpp:23–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21 * Ensure that the mempool won't accept coinbase transactions.
22 */
23BOOST_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}
52BOOST_AUTO_TEST_SUITE_END()

Callers

nothing calls this directly

Calls 12

ToByteVectorFunction · 0.85
ProcessTransactionMethod · 0.80
IsInvalidMethod · 0.80
GetRejectReasonMethod · 0.80
GetResultMethod · 0.80
CScriptClass · 0.50
CTransactionClass · 0.50
MakeTransactionRefFunction · 0.50
GetPubKeyMethod · 0.45
resizeMethod · 0.45
IsCoinBaseMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected