MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / DoTest

Function DoTest

src/test/script_tests.cpp:150–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, int flags, const std::string& message, int scriptError, CAmount nValue)
151{
152 bool expect = (scriptError == SCRIPT_ERR_OK);
153 ScriptError err;
154 CMutableTransaction txCredit = BuildCreditingTransaction(scriptPubKey, nValue);
155 CMutableTransaction tx = BuildSpendingTransaction(scriptSig, txCredit);
156 CMutableTransaction tx2 = tx;
157 BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, flags, MutableTransactionSignatureChecker(&tx, 0, txCredit.vout[0].nValue), &err) == expect, message);
158 BOOST_CHECK_MESSAGE(err == scriptError, std::string(FormatScriptError(err)) + " where " + std::string(FormatScriptError((ScriptError_t)scriptError)) + " expected: " + message);
159#if defined(HAVE_CONSENSUS_LIB)
160 CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
161 stream << tx2;
162 if (nValue == 0) {
163 BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script(begin_ptr(scriptPubKey), scriptPubKey.size(), (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect,message);
164 }
165#endif
166}
167
168void static NegateSignatureS(std::vector<unsigned char>& vchSig) {
169 // Parse the signature.

Callers 2

TestBuilderClass · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 8

BuildSpendingTransactionFunction · 0.85
VerifyScriptFunction · 0.85
FormatScriptErrorFunction · 0.85
begin_ptrFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected