Changeset View
Changeset View
Standalone View
Standalone View
src/test/txvalidation_tests.cpp
Show All 32 Lines | BOOST_FIXTURE_TEST_CASE(tx_mempool_reject_coinbase, TestChain100Setup) { | ||||
assert(CTransaction(coinbaseTx).IsCoinBase()); | assert(CTransaction(coinbaseTx).IsCoinBase()); | ||||
CValidationState state; | CValidationState state; | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
unsigned int initialPoolSize = g_mempool.size(); | unsigned int initialPoolSize = g_mempool.size(); | ||||
BOOST_CHECK_EQUAL( | BOOST_CHECK_EQUAL(false, | ||||
false, | AcceptToMemoryPool(GetConfig(), g_mempool, state, | ||||
AcceptToMemoryPool( | MakeTransactionRef(coinbaseTx), | ||||
GetConfig(), g_mempool, state, MakeTransactionRef(coinbaseTx), | nullptr /* pfMissingInputs */, | ||||
false /* pfMissingInputs */, nullptr /* plTxnReplaced */, | true /* bypass_limits */, | ||||
true /* bypass_limits */, Amount::zero() /* nAbsurdFee */)); | Amount::zero() /* nAbsurdFee */)); | ||||
// Check that the transaction hasn't been added to mempool. | // Check that the transaction hasn't been added to mempool. | ||||
BOOST_CHECK_EQUAL(g_mempool.size(), initialPoolSize); | BOOST_CHECK_EQUAL(g_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(state.IsInvalid()); | ||||
BOOST_CHECK_EQUAL(state.GetRejectReason(), "bad-tx-coinbase"); | BOOST_CHECK_EQUAL(state.GetRejectReason(), "bad-tx-coinbase"); | ||||
int nDoS; | int nDoS; | ||||
BOOST_CHECK_EQUAL(state.IsInvalid(nDoS), true); | BOOST_CHECK_EQUAL(state.IsInvalid(nDoS), true); | ||||
BOOST_CHECK_EQUAL(nDoS, 100); | BOOST_CHECK_EQUAL(nDoS, 100); | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |