Changeset View
Changeset View
Standalone View
Standalone View
src/test/script_tests.cpp
Show First 20 Lines • Show All 2,760 Lines • ▼ Show 20 Lines | for (unsigned int i = 0; i <= MAX_SCRIPT_ELEMENT_SIZE; i++) { | ||||
BOOST_CHECK_MESSAGE(VerifyScript(script, CScript() << OP_1, | BOOST_CHECK_MESSAGE(VerifyScript(script, CScript() << OP_1, | ||||
SCRIPT_VERIFY_MINIMALDATA, | SCRIPT_VERIFY_MINIMALDATA, | ||||
BaseSignatureChecker(), &err), | BaseSignatureChecker(), &err), | ||||
"Length " << i << " push is not minimal data."); | "Length " << i << " push is not minimal data."); | ||||
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); | BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(script_IsPushOnly_on_invalid_scripts) { | |||||
// IsPushOnly returns false when given a script containing only pushes that | |||||
// are invalid due to truncation. IsPushOnly() is consensus critical because | |||||
// P2SH evaluation uses it, although this specific behavior should not be | |||||
// consensus critical as the P2SH evaluation would fail first due to the | |||||
// invalid push. Still, it doesn't hurt to test it explicitly. | |||||
static const uint8_t direct[] = {1}; | |||||
BOOST_CHECK(!CScript(direct, direct + sizeof(direct)).IsPushOnly()); | |||||
} | |||||
BOOST_AUTO_TEST_CASE(script_GetScriptAsm) { | BOOST_AUTO_TEST_CASE(script_GetScriptAsm) { | ||||
BOOST_CHECK_EQUAL("OP_CHECKLOCKTIMEVERIFY", | BOOST_CHECK_EQUAL("OP_CHECKLOCKTIMEVERIFY", | ||||
ScriptToAsmStr(CScript() << OP_NOP2, true)); | ScriptToAsmStr(CScript() << OP_NOP2, true)); | ||||
BOOST_CHECK_EQUAL( | BOOST_CHECK_EQUAL( | ||||
"OP_CHECKLOCKTIMEVERIFY", | "OP_CHECKLOCKTIMEVERIFY", | ||||
ScriptToAsmStr(CScript() << OP_CHECKLOCKTIMEVERIFY, true)); | ScriptToAsmStr(CScript() << OP_CHECKLOCKTIMEVERIFY, true)); | ||||
BOOST_CHECK_EQUAL("OP_CHECKLOCKTIMEVERIFY", | BOOST_CHECK_EQUAL("OP_CHECKLOCKTIMEVERIFY", | ||||
ScriptToAsmStr(CScript() << OP_NOP2)); | ScriptToAsmStr(CScript() << OP_NOP2)); | ||||
▲ Show 20 Lines • Show All 276 Lines • Show Last 20 Lines |