Changeset View
Changeset View
Standalone View
Standalone View
src/test/monolith_opcodes_tests.cpp
Show First 20 Lines • Show All 625 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(type_conversion_test) { | ||||
// NUM2BIN must not generate oversized push. | // NUM2BIN must not generate oversized push. | ||||
valtype largezero(MAX_SCRIPT_ELEMENT_SIZE, 0); | valtype largezero(MAX_SCRIPT_ELEMENT_SIZE, 0); | ||||
BOOST_CHECK_EQUAL(largezero.size(), MAX_SCRIPT_ELEMENT_SIZE); | BOOST_CHECK_EQUAL(largezero.size(), MAX_SCRIPT_ELEMENT_SIZE); | ||||
CheckTypeConversionOp(largezero, {}); | CheckTypeConversionOp(largezero, {}); | ||||
CheckNum2BinError({{}, {0x09, 0x02}}, SCRIPT_ERR_PUSH_SIZE); | CheckNum2BinError({{}, {0x09, 0x02}}, SCRIPT_ERR_PUSH_SIZE); | ||||
// NUM2BIN can't take negative sizes, for which it throws an error | // NUM2BIN can't take negative sizes, giving an appropriate error. | ||||
// "Push value size limit exceeded" | CheckNum2BinError({{}, {0x81}}, SCRIPT_ERR_NEGATIVE_NUMBER); | ||||
CheckNum2BinError({{}, {0x81}}, SCRIPT_ERR_PUSH_SIZE); | |||||
// ... except for negative zero of course (without minimaldata flag) | // ... except for negative zero of course (without minimaldata flag) | ||||
CheckTestResult(0, {{0x00, 0x80}, {0x80}}, CScript() << OP_NUM2BIN, {{}}); | CheckTestResult(0, {{0x00, 0x80}, {0x80}}, CScript() << OP_NUM2BIN, {{}}); | ||||
CheckTestResult(0, {{0x00, 0x80}, {0x00, 0x80}}, CScript() << OP_NUM2BIN, | CheckTestResult(0, {{0x00, 0x80}, {0x00, 0x80}}, CScript() << OP_NUM2BIN, | ||||
{{}}); | {{}}); | ||||
// Check that the requested encoding is possible. | // Check that the requested encoding is possible. | ||||
CheckNum2BinError({{0xab, 0xcd, 0xef, 0x80}, {0x03}}, | CheckNum2BinError({{0xab, 0xcd, 0xef, 0x80}, {0x03}}, | ||||
SCRIPT_ERR_IMPOSSIBLE_ENCODING); | SCRIPT_ERR_IMPOSSIBLE_ENCODING); | ||||
▲ Show 20 Lines • Show All 140 Lines • Show Last 20 Lines |