Changeset View
Changeset View
Standalone View
Standalone View
src/test/sigopcount_tests.cpp
Show First 20 Lines • Show All 247 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(test_max_sigops_per_tx) { | ||||
tx.vin[0].prevout = COutPoint(InsecureRand256(), 0); | tx.vin[0].prevout = COutPoint(InsecureRand256(), 0); | ||||
tx.vin[0].scriptSig = CScript(); | tx.vin[0].scriptSig = CScript(); | ||||
tx.vout.resize(1); | tx.vout.resize(1); | ||||
tx.vout[0].nValue = SATOSHI; | tx.vout[0].nValue = SATOSHI; | ||||
tx.vout[0].scriptPubKey = CScript(); | tx.vout[0].scriptPubKey = CScript(); | ||||
{ | { | ||||
CValidationState state; | CValidationState state; | ||||
BOOST_CHECK(CheckRegularTransaction(CTransaction(tx), state, false)); | BOOST_CHECK(CheckRegularTransaction(CTransaction(tx), state)); | ||||
} | } | ||||
// Get just before the limit. | // Get just before the limit. | ||||
for (size_t i = 0; i < MAX_TX_SIGOPS_COUNT; i++) { | for (size_t i = 0; i < MAX_TX_SIGOPS_COUNT; i++) { | ||||
tx.vout[0].scriptPubKey << OP_CHECKSIG; | tx.vout[0].scriptPubKey << OP_CHECKSIG; | ||||
} | } | ||||
{ | { | ||||
CValidationState state; | CValidationState state; | ||||
BOOST_CHECK(CheckRegularTransaction(CTransaction(tx), state, false)); | BOOST_CHECK(CheckRegularTransaction(CTransaction(tx), state)); | ||||
} | } | ||||
// And go over. | // And go over. | ||||
tx.vout[0].scriptPubKey << OP_CHECKSIG; | tx.vout[0].scriptPubKey << OP_CHECKSIG; | ||||
{ | { | ||||
CValidationState state; | CValidationState state; | ||||
BOOST_CHECK(!CheckRegularTransaction(CTransaction(tx), state, false)); | BOOST_CHECK(!CheckRegularTransaction(CTransaction(tx), state)); | ||||
BOOST_CHECK_EQUAL(state.GetRejectReason(), "bad-txn-sigops"); | BOOST_CHECK_EQUAL(state.GetRejectReason(), "bad-txn-sigops"); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |