Changeset View
Changeset View
Standalone View
Standalone View
src/test/script_tests.cpp
Show First 20 Lines • Show All 1,319 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(script_build) { | ||||
std::string strGen; | std::string strGen; | ||||
for (TestBuilder &test : tests) { | for (TestBuilder &test : tests) { | ||||
test.Test(); | test.Test(); | ||||
std::string str = JSONPrettyPrint(test.GetJSON()); | std::string str = JSONPrettyPrint(test.GetJSON()); | ||||
#ifndef UPDATE_JSON_TESTS | #ifndef UPDATE_JSON_TESTS | ||||
if (tests_set.count(str) == 0) { | if (tests_set.count(str) == 0) { | ||||
BOOST_CHECK_MESSAGE( | BOOST_CHECK_MESSAGE(false, "Missing auto script_valid test: " + | ||||
false, "Missing auto script_valid test: " + test.GetComment()); | test.GetComment()); | ||||
} | } | ||||
#endif | #endif | ||||
strGen += str + ",\n"; | strGen += str + ",\n"; | ||||
} | } | ||||
#ifdef UPDATE_JSON_TESTS | #ifdef UPDATE_JSON_TESTS | ||||
FILE *file = fopen("script_tests.json.gen", "w"); | FILE *file = fopen("script_tests.json.gen", "w"); | ||||
fputs(strGen.c_str(), file); | fputs(strGen.c_str(), file); | ||||
▲ Show 20 Lines • Show All 351 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(script_combineSigs) { | ||||
SignSignature(keystore, CTransaction(txFrom), txTo, 0, SigHashType()); | SignSignature(keystore, CTransaction(txFrom), txTo, 0, SigHashType()); | ||||
combined = CombineSignatures( | combined = CombineSignatures( | ||||
scriptPubKey, MutableTransactionSignatureChecker(&txTo, 0, amount), | scriptPubKey, MutableTransactionSignatureChecker(&txTo, 0, amount), | ||||
SignatureData(scriptSigCopy), SignatureData(scriptSig)); | SignatureData(scriptSigCopy), SignatureData(scriptSig)); | ||||
BOOST_CHECK(combined.scriptSig == scriptSigCopy || | BOOST_CHECK(combined.scriptSig == scriptSigCopy || | ||||
combined.scriptSig == scriptSig); | combined.scriptSig == scriptSig); | ||||
// dummy scriptSigCopy with placeholder, should always choose | // dummy scriptSigCopy with placeholder, should always choose | ||||
// non-placeholder: | // non-placeholder: | ||||
scriptSigCopy = CScript() << OP_0 << std::vector<uint8_t>(pkSingle.begin(), | scriptSigCopy = CScript() | ||||
pkSingle.end()); | << OP_0 | ||||
<< std::vector<uint8_t>(pkSingle.begin(), pkSingle.end()); | |||||
combined = CombineSignatures( | combined = CombineSignatures( | ||||
scriptPubKey, MutableTransactionSignatureChecker(&txTo, 0, amount), | scriptPubKey, MutableTransactionSignatureChecker(&txTo, 0, amount), | ||||
SignatureData(scriptSigCopy), SignatureData(scriptSig)); | SignatureData(scriptSigCopy), SignatureData(scriptSig)); | ||||
BOOST_CHECK(combined.scriptSig == scriptSig); | BOOST_CHECK(combined.scriptSig == scriptSig); | ||||
combined = CombineSignatures( | combined = CombineSignatures( | ||||
scriptPubKey, MutableTransactionSignatureChecker(&txTo, 0, amount), | scriptPubKey, MutableTransactionSignatureChecker(&txTo, 0, amount), | ||||
SignatureData(scriptSig), SignatureData(scriptSigCopy)); | SignatureData(scriptSig), SignatureData(scriptSigCopy)); | ||||
BOOST_CHECK(combined.scriptSig == scriptSig); | BOOST_CHECK(combined.scriptSig == scriptSig); | ||||
▲ Show 20 Lines • Show All 363 Lines • Show Last 20 Lines |