Changeset View
Changeset View
Standalone View
Standalone View
src/test/sigopcount_tests.cpp
Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(GetSigOpCount) { | ||||
const CScript s5 = CScript(s4) << OP_CHECKDATASIGVERIFY; | const CScript s5 = CScript(s4) << OP_CHECKDATASIGVERIFY; | ||||
CheckScriptSigOps(s5, 2, 20, 2); | CheckScriptSigOps(s5, 2, 20, 2); | ||||
} | } | ||||
/** | /** | ||||
* Verifies script execution of the zeroth scriptPubKey of tx output and zeroth | * Verifies script execution of the zeroth scriptPubKey of tx output and zeroth | ||||
* scriptSig of tx input. | * scriptSig of tx input. | ||||
*/ | */ | ||||
ScriptError VerifyWithFlag(const CTransaction &output, | static ScriptError VerifyWithFlag(const CTransaction &output, | ||||
const CMutableTransaction &input, int flags) { | const CMutableTransaction &input, int flags) { | ||||
ScriptError error; | ScriptError error; | ||||
CTransaction inputi(input); | CTransaction inputi(input); | ||||
bool ret = VerifyScript( | bool ret = VerifyScript( | ||||
inputi.vin[0].scriptSig, output.vout[0].scriptPubKey, flags, | inputi.vin[0].scriptSig, output.vout[0].scriptPubKey, flags, | ||||
TransactionSignatureChecker(&inputi, 0, output.vout[0].nValue), &error); | TransactionSignatureChecker(&inputi, 0, output.vout[0].nValue), &error); | ||||
BOOST_CHECK_EQUAL((ret == true), (error == SCRIPT_ERR_OK)); | BOOST_CHECK_EQUAL((ret == true), (error == SCRIPT_ERR_OK)); | ||||
return error; | return error; | ||||
} | } | ||||
/** | /** | ||||
* Builds a creationTx from scriptPubKey and a spendingTx from scriptSig | * Builds a creationTx from scriptPubKey and a spendingTx from scriptSig | ||||
* such that spendingTx spends output zero of creationTx. Also inserts | * such that spendingTx spends output zero of creationTx. Also inserts | ||||
* creationTx's output into the coins view. | * creationTx's output into the coins view. | ||||
*/ | */ | ||||
void BuildTxs(CMutableTransaction &spendingTx, CCoinsViewCache &coins, | static void BuildTxs(CMutableTransaction &spendingTx, CCoinsViewCache &coins, | ||||
CMutableTransaction &creationTx, const CScript &scriptPubKey, | CMutableTransaction &creationTx, | ||||
const CScript &scriptSig) { | const CScript &scriptPubKey, const CScript &scriptSig) { | ||||
creationTx.nVersion = 1; | creationTx.nVersion = 1; | ||||
creationTx.vin.resize(1); | creationTx.vin.resize(1); | ||||
creationTx.vin[0].prevout = COutPoint(); | creationTx.vin[0].prevout = COutPoint(); | ||||
creationTx.vin[0].scriptSig = CScript(); | creationTx.vin[0].scriptSig = CScript(); | ||||
creationTx.vout.resize(1); | creationTx.vout.resize(1); | ||||
creationTx.vout[0].nValue = SATOSHI; | creationTx.vout[0].nValue = SATOSHI; | ||||
creationTx.vout[0].scriptPubKey = scriptPubKey; | creationTx.vout[0].scriptPubKey = scriptPubKey; | ||||
▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines |