diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2014-09-12 18:32:15 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2014-09-12 18:33:02 +0200 |
commit | b9307d2f55710cfc5f74bbc68c7e8db8091677e8 (patch) | |
tree | 1fc8d85d81f5e1a10d6ff1f8e47d6ff0ba028846 /src/test/script_tests.cpp | |
parent | 6a830ec947a432841f069b875cfb955c7c1e608b (diff) | |
parent | 6022b5dc6ba930797db46e00426923b53d6594b3 (diff) |
Merge pull request #4876
6022b5d Make script_{valid,invalid}.json validation flags configurable (Pieter Wuille)
Diffstat (limited to 'src/test/script_tests.cpp')
-rw-r--r-- | src/test/script_tests.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 88efc38964..bc610778c4 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -35,6 +35,8 @@ using namespace boost::algorithm; static const unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC; +unsigned int ParseScriptFlags(string strFlags); + Array read_json(const std::string& jsondata) { @@ -54,7 +56,7 @@ BOOST_AUTO_TEST_CASE(script_valid) { // Read tests from test/data/script_valid.json // Format is an array of arrays - // Inner arrays are [ "scriptSig", "scriptPubKey" ] + // Inner arrays are [ "scriptSig", "scriptPubKey", "flags" ] // ... where scriptSig and scriptPubKey are stringified // scripts. Array tests = read_json(std::string(json_tests::script_valid, json_tests::script_valid + sizeof(json_tests::script_valid))); @@ -63,7 +65,7 @@ BOOST_AUTO_TEST_CASE(script_valid) { Array test = tv.get_array(); string strTest = write_string(tv, false); - if (test.size() < 2) // Allow size > 2; extra stuff ignored (useful for comments) + if (test.size() < 3) // Allow size > 3; extra stuff ignored (useful for comments) { BOOST_ERROR("Bad test: " << strTest); continue; @@ -72,9 +74,10 @@ BOOST_AUTO_TEST_CASE(script_valid) CScript scriptSig = ParseScript(scriptSigString); string scriptPubKeyString = test[1].get_str(); CScript scriptPubKey = ParseScript(scriptPubKeyString); + unsigned int scriptflags = ParseScriptFlags(test[2].get_str()); CTransaction tx; - BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, tx, 0, flags, SIGHASH_NONE), strTest); + BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, tx, 0, scriptflags, SIGHASH_NONE), strTest); } } @@ -96,9 +99,10 @@ BOOST_AUTO_TEST_CASE(script_invalid) CScript scriptSig = ParseScript(scriptSigString); string scriptPubKeyString = test[1].get_str(); CScript scriptPubKey = ParseScript(scriptPubKeyString); + unsigned int scriptflags = ParseScriptFlags(test[2].get_str()); CTransaction tx; - BOOST_CHECK_MESSAGE(!VerifyScript(scriptSig, scriptPubKey, tx, 0, flags, SIGHASH_NONE), strTest); + BOOST_CHECK_MESSAGE(!VerifyScript(scriptSig, scriptPubKey, tx, 0, scriptflags, SIGHASH_NONE), strTest); } } |