aboutsummaryrefslogtreecommitdiff
path: root/src/test/script_tests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/script_tests.cpp')
-rw-r--r--src/test/script_tests.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index 77c44501ab..bc610778c4 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -2,15 +2,14 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include "script.h"
-
#include "data/script_invalid.json.h"
#include "data/script_valid.json.h"
#include "key.h"
#include "keystore.h"
#include "main.h"
-#include "script.h"
+#include "script/script.h"
+#include "script/sign.h"
#include "core_io.h"
#include <fstream>
@@ -36,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)
{
@@ -55,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)));
@@ -64,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;
@@ -73,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);
}
}
@@ -97,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);
}
}