Changeset View
Changeset View
Standalone View
Standalone View
src/test/sigopcount_tests.cpp
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | |||||
void BuildTxs(CMutableTransaction &spendingTx, CCoinsViewCache &coins, | void BuildTxs(CMutableTransaction &spendingTx, CCoinsViewCache &coins, | ||||
CMutableTransaction &creationTx, const CScript &scriptPubKey, | CMutableTransaction &creationTx, const CScript &scriptPubKey, | ||||
const CScript &scriptSig) { | const CScript &scriptSig) { | ||||
creationTx.nVersion = 1; | creationTx.nVersion = 1; | ||||
creationTx.vin.resize(1); | creationTx.vin.resize(1); | ||||
creationTx.vin[0].prevout.SetNull(); | creationTx.vin[0].prevout.SetNull(); | ||||
creationTx.vin[0].scriptSig = CScript(); | creationTx.vin[0].scriptSig = CScript(); | ||||
creationTx.vout.resize(1); | creationTx.vout.resize(1); | ||||
creationTx.vout[0].nValue = 1; | creationTx.vout[0].nValue = Amount(1); | ||||
creationTx.vout[0].scriptPubKey = scriptPubKey; | creationTx.vout[0].scriptPubKey = scriptPubKey; | ||||
spendingTx.nVersion = 1; | spendingTx.nVersion = 1; | ||||
spendingTx.vin.resize(1); | spendingTx.vin.resize(1); | ||||
spendingTx.vin[0].prevout.hash = creationTx.GetId(); | spendingTx.vin[0].prevout.hash = creationTx.GetId(); | ||||
spendingTx.vin[0].prevout.n = 0; | spendingTx.vin[0].prevout.n = 0; | ||||
spendingTx.vin[0].scriptSig = scriptSig; | spendingTx.vin[0].scriptSig = scriptSig; | ||||
spendingTx.vout.resize(1); | spendingTx.vout.resize(1); | ||||
spendingTx.vout[0].nValue = 1; | spendingTx.vout[0].nValue = Amount(1); | ||||
spendingTx.vout[0].scriptPubKey = CScript(); | spendingTx.vout[0].scriptPubKey = CScript(); | ||||
AddCoins(coins, creationTx, 0); | AddCoins(coins, creationTx, 0); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(GetTxSigOpCost) { | BOOST_AUTO_TEST_CASE(GetTxSigOpCost) { | ||||
// Transaction creates outputs | // Transaction creates outputs | ||||
CMutableTransaction creationTx; | CMutableTransaction creationTx; | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | |||||
BOOST_AUTO_TEST_CASE(test_max_sigops_per_tx) { | BOOST_AUTO_TEST_CASE(test_max_sigops_per_tx) { | ||||
CMutableTransaction tx; | CMutableTransaction tx; | ||||
tx.nVersion = 1; | tx.nVersion = 1; | ||||
tx.vin.resize(1); | tx.vin.resize(1); | ||||
tx.vin[0].prevout.hash = GetRandHash(); | tx.vin[0].prevout.hash = GetRandHash(); | ||||
tx.vin[0].prevout.n = 0; | tx.vin[0].prevout.n = 0; | ||||
tx.vin[0].scriptSig = CScript(); | tx.vin[0].scriptSig = CScript(); | ||||
tx.vout.resize(1); | tx.vout.resize(1); | ||||
tx.vout[0].nValue = 1; | tx.vout[0].nValue = Amount(1); | ||||
tx.vout[0].scriptPubKey = CScript(); | tx.vout[0].scriptPubKey = CScript(); | ||||
{ | { | ||||
CValidationState state; | CValidationState state; | ||||
BOOST_CHECK(CheckRegularTransaction(tx, state, false)); | BOOST_CHECK(CheckRegularTransaction(tx, state, false)); | ||||
} | } | ||||
// Get just before the limit. | // Get just before the limit. | ||||
Show All 20 Lines |