aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-06-08 12:48:46 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2017-06-08 13:36:48 +0200
commit9c248e39f2807a7f89e555e99cc55cb2de1ad335 (patch)
tree23d98e7fdeec7350b6ff274775cce9ee91d5e13c /src/test
parent35e7f13f68f970d036606e111429ae34750c363a (diff)
parentac4e438229134595e949bfedb1f487c71fd45d24 (diff)
Merge #10481: Decodehextx scripts sanity check
ac4e438 Sanity check transaction scripts in DecodeHexTx (Andrew Chow) 5b75c47 Add a valid opcode sanity check to CScript (Andrew Chow) Tree-SHA512: a516e95c274c9d131123150c798cae8bed75925e8a4d59469967dd7f1d49f7f8161e26afb61024b821bd8dcdffdfd0d19b8dcad20b39b1106820326d8d56904d
Diffstat (limited to 'src/test')
-rw-r--r--src/test/script_tests.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index 343c645cb1..70544cacd6 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -1438,4 +1438,18 @@ BOOST_AUTO_TEST_CASE(script_FindAndDelete)
BOOST_CHECK(s == expect);
}
+BOOST_AUTO_TEST_CASE(script_HasValidOps)
+{
+ // Exercise the HasValidOps functionality
+ CScript script;
+ script = ScriptFromHex("76a9141234567890abcdefa1a2a3a4a5a6a7a8a9a0aaab88ac"); // Normal script
+ BOOST_CHECK(script.HasValidOps());
+ script = ScriptFromHex("76a914ff34567890abcdefa1a2a3a4a5a6a7a8a9a0aaab88ac");
+ BOOST_CHECK(script.HasValidOps());
+ script = ScriptFromHex("ff88ac"); // Script with OP_INVALIDOPCODE explicit
+ BOOST_CHECK(!script.HasValidOps());
+ script = ScriptFromHex("88acc0"); // Script with undefined opcode
+ BOOST_CHECK(!script.HasValidOps());
+}
+
BOOST_AUTO_TEST_SUITE_END()