diff options
| author | Wladimir J. van der Laan <[email protected]> | 2016-11-07 13:40:19 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2016-11-07 13:41:39 +0100 |
| commit | 8c6218a28ae8941fc07cc1324ade9588e1ffd4d9 (patch) | |
| tree | d4f00665677d602641791b631e29ee37acac4fcf /src/test/script_tests.cpp | |
| parent | Merge #7730: Remove priority estimation (diff) | |
| parent | libconsensus: Add input validation of flags (diff) | |
| download | discoin-8c6218a28ae8941fc07cc1324ade9588e1ffd4d9.tar.xz discoin-8c6218a28ae8941fc07cc1324ade9588e1ffd4d9.zip | |
Merge #8976: libconsensus: Add input validation of flags
5ca8ef2 libconsensus: Add input validation of flags (Wladimir J. van der Laan)
Diffstat (limited to 'src/test/script_tests.cpp')
| -rw-r--r-- | src/test/script_tests.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 561adb8ea..3169afb13 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -173,11 +173,14 @@ void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, const CScript #if defined(HAVE_CONSENSUS_LIB) CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << tx2; - if (flags & bitcoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS) { - BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script_with_amount(begin_ptr(scriptPubKey), scriptPubKey.size(), txCredit.vout[0].nValue, (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect, message); - } else { - BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script_with_amount(begin_ptr(scriptPubKey), scriptPubKey.size(), 0, (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect, message); - BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script(begin_ptr(scriptPubKey), scriptPubKey.size(), (const unsigned char*)&stream[0], stream.size(), 0, flags, NULL) == expect,message); + int libconsensus_flags = flags & bitcoinconsensus_SCRIPT_FLAGS_VERIFY_ALL; + if (libconsensus_flags == flags) { + if (flags & bitcoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS) { + BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script_with_amount(begin_ptr(scriptPubKey), scriptPubKey.size(), txCredit.vout[0].nValue, (const unsigned char*)&stream[0], stream.size(), 0, libconsensus_flags, NULL) == expect, message); + } else { + BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script_with_amount(begin_ptr(scriptPubKey), scriptPubKey.size(), 0, (const unsigned char*)&stream[0], stream.size(), 0, libconsensus_flags, NULL) == expect, message); + BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script(begin_ptr(scriptPubKey), scriptPubKey.size(), (const unsigned char*)&stream[0], stream.size(), 0, libconsensus_flags, NULL) == expect,message); + } } #endif } |