Changeset View
Changeset View
Standalone View
Standalone View
src/test/script_tests.cpp
Show First 20 Lines • Show All 3,020 Lines • ▼ Show 20 Lines | // Tests with 1 and 3 stack elements | ||||
CScript script; | CScript script; | ||||
script << OP_0 << std::vector<uint8_t>(20, '\42') << OP_1; | script << OP_0 << std::vector<uint8_t>(20, '\42') << OP_1; | ||||
BOOST_CHECK_MESSAGE( | BOOST_CHECK_MESSAGE( | ||||
!script.IsWitnessProgram(), | !script.IsWitnessProgram(), | ||||
"Failed IsWitnessProgram check with 3 stack elements"); | "Failed IsWitnessProgram check with 3 stack elements"); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(script_HasValidOps) { | |||||
// Exercise the HasValidOps functionality | |||||
CScript script; | |||||
// Normal script | |||||
script = | |||||
ScriptFromHex("76a9141234567890abcdefa1a2a3a4a5a6a7a8a9a0aaab88ac"); | |||||
BOOST_CHECK(script.HasValidOps()); | |||||
script = | |||||
ScriptFromHex("76a914ff34567890abcdefa1a2a3a4a5a6a7a8a9a0aaab88ac"); | |||||
BOOST_CHECK(script.HasValidOps()); | |||||
// Script with OP_INVALIDOPCODE explicit | |||||
script = ScriptFromHex("ff88ac"); | |||||
BOOST_CHECK(!script.HasValidOps()); | |||||
// Script with undefined opcode | |||||
script = ScriptFromHex("88acc0"); | |||||
BOOST_CHECK(!script.HasValidOps()); | |||||
// Check all non push opcodes. | |||||
for (uint8_t opcode = OP_1NEGATE; opcode < FIRST_UNDEFINED_OP_VALUE; | |||||
opcode++) { | |||||
script = CScript() << opcode; | |||||
BOOST_CHECK(script.HasValidOps()); | |||||
} | |||||
script = CScript() << FIRST_UNDEFINED_OP_VALUE; | |||||
BOOST_CHECK(!script.HasValidOps()); | |||||
} | |||||
BOOST_AUTO_TEST_CASE(script_can_append_self) { | BOOST_AUTO_TEST_CASE(script_can_append_self) { | ||||
CScript s, d; | CScript s, d; | ||||
s = ScriptFromHex("00"); | s = ScriptFromHex("00"); | ||||
s += s; | s += s; | ||||
d = ScriptFromHex("0000"); | d = ScriptFromHex("0000"); | ||||
BOOST_CHECK(s == d); | BOOST_CHECK(s == d); | ||||
Show All 12 Lines |