diff options
| author | Pieter Wuille <[email protected]> | 2017-06-28 16:29:14 -0700 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2017-06-30 16:14:13 -0700 |
| commit | 2dd6f80680b8cbf9d4c99c6b2a8310af541e9aa3 (patch) | |
| tree | f792de4a412e5cb650cd6978363054723df14839 /src/test/script_tests.cpp | |
| parent | Make all script verification flags softforks (diff) | |
| download | discoin-2dd6f80680b8cbf9d4c99c6b2a8310af541e9aa3.tar.xz discoin-2dd6f80680b8cbf9d4c99c6b2a8310af541e9aa3.zip | |
Add a test that all flags are softforks
Diffstat (limited to 'src/test/script_tests.cpp')
| -rw-r--r-- | src/test/script_tests.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 1bb191c73..f1a3d2d03 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -167,6 +167,17 @@ void DoTest(const CScript& scriptPubKey, const CScript& scriptSig, const CScript CMutableTransaction tx2 = tx; BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, &scriptWitness, flags, MutableTransactionSignatureChecker(&tx, 0, txCredit.vout[0].nValue), &err) == expect, message); BOOST_CHECK_MESSAGE(err == scriptError, std::string(FormatScriptError(err)) + " where " + std::string(FormatScriptError((ScriptError_t)scriptError)) + " expected: " + message); + + // Verify that removing flags from a passing test or adding flags to a failing test does not change the result. + for (int i = 0; i < 16; ++i) { + int extra_flags = InsecureRandBits(16); + int combined_flags = expect ? (flags & ~extra_flags) : (flags | extra_flags); + // Weed out some invalid flag combinations. + if (combined_flags & SCRIPT_VERIFY_CLEANSTACK && ~combined_flags & (SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS)) continue; + if (combined_flags & SCRIPT_VERIFY_WITNESS && ~combined_flags & SCRIPT_VERIFY_P2SH) continue; + BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, &scriptWitness, combined_flags, MutableTransactionSignatureChecker(&tx, 0, txCredit.vout[0].nValue), &err) == expect, message + strprintf(" (with flags %x)", combined_flags)); + } + #if defined(HAVE_CONSENSUS_LIB) CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << tx2; |