Changeset View
Changeset View
Standalone View
Standalone View
src/test/checkdatasig_tests.cpp
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
* General utility functions to check for script passing/failing. | * General utility functions to check for script passing/failing. | ||||
*/ | */ | ||||
static void CheckTestResultForAllFlags(const stacktype &original_stack, | static void CheckTestResultForAllFlags(const stacktype &original_stack, | ||||
const CScript &script, | const CScript &script, | ||||
const stacktype &expected) { | const stacktype &expected) { | ||||
for (uint32_t flags : flagset) { | for (uint32_t flags : flagset) { | ||||
// Make sure that we get a bad opcode when the activation flag is not | // Make sure that we get a bad opcode when the activation flag is not | ||||
// passed. | // passed. | ||||
CheckError(flags, original_stack, script, SCRIPT_ERR_BAD_OPCODE); | CheckError(flags & ~SCRIPT_ENABLE_CHECKDATASIG, original_stack, script, | ||||
SCRIPT_ERR_BAD_OPCODE); | |||||
// The script execute as expected if the opcodes are activated. | // The script execute as expected if the opcodes are activated. | ||||
CheckPass(flags | SCRIPT_ENABLE_CHECKDATASIG, original_stack, script, | CheckPass(flags | SCRIPT_ENABLE_CHECKDATASIG, original_stack, script, | ||||
expected); | expected); | ||||
} | } | ||||
} | } | ||||
static void CheckErrorForAllFlags(const stacktype &original_stack, | static void CheckErrorForAllFlags(const stacktype &original_stack, | ||||
const CScript &script, ScriptError expected) { | const CScript &script, ScriptError expected) { | ||||
for (uint32_t flags : flagset) { | for (uint32_t flags : flagset) { | ||||
// Make sure that we get a bad opcode when the activation flag is not | // Make sure that we get a bad opcode when the activation flag is not | ||||
// passed. | // passed. | ||||
CheckError(flags, original_stack, script, SCRIPT_ERR_BAD_OPCODE); | CheckError(flags & ~SCRIPT_ENABLE_CHECKDATASIG, original_stack, script, | ||||
SCRIPT_ERR_BAD_OPCODE); | |||||
// The script generates the proper error if the opcodes are activated. | // The script generates the proper error if the opcodes are activated. | ||||
CheckError(flags | SCRIPT_ENABLE_CHECKDATASIG, original_stack, script, | CheckError(flags | SCRIPT_ENABLE_CHECKDATASIG, original_stack, script, | ||||
expected); | expected); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(checkdatasig_test) { | BOOST_AUTO_TEST_CASE(checkdatasig_test) { | ||||
▲ Show 20 Lines • Show All 163 Lines • Show Last 20 Lines |