Changeset View
Changeset View
Standalone View
Standalone View
src/test/script_standard_tests.cpp
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(script_standard_Solver_success) { | ||||
BOOST_CHECK_EQUAL(solutions.size(), 0); | BOOST_CHECK_EQUAL(solutions.size(), 0); | ||||
// TX_NONSTANDARD | // TX_NONSTANDARD | ||||
s.clear(); | s.clear(); | ||||
s << OP_9 << OP_ADD << OP_11 << OP_EQUAL; | s << OP_9 << OP_ADD << OP_11 << OP_EQUAL; | ||||
BOOST_CHECK(!Solver(s, whichType, solutions)); | BOOST_CHECK(!Solver(s, whichType, solutions)); | ||||
BOOST_CHECK_EQUAL(whichType, TX_NONSTANDARD); | BOOST_CHECK_EQUAL(whichType, TX_NONSTANDARD); | ||||
BOOST_CHECK_EQUAL(solutions.size(), 0); | BOOST_CHECK_EQUAL(solutions.size(), 0); | ||||
// Try some non-minimal forms of various standard scripts | |||||
jasonbcox: nit: each set of tests should be commented to make it clear which script type is intended to be… | |||||
s.clear(); | |||||
s << OP_PUSHDATA1 << ToByteVector(pubkeys[0]) << OP_CHECKSIG; | |||||
jasonbcoxUnsubmitted Not Done Inline ActionsLoop through all OP_PUSHDATAx that could be used to make non-minimal forms to improve test coverage. jasonbcox: Loop through all OP_PUSHDATAx that could be used to make non-minimal forms to improve test… | |||||
BOOST_CHECK(!Solver(s, whichType, solutions)); | |||||
BOOST_CHECK_EQUAL(whichType, TX_NONSTANDARD); | |||||
BOOST_CHECK_EQUAL(solutions.size(), 0); | |||||
s.clear(); | |||||
s << OP_DUP << OP_HASH160 << OP_PUSHDATA1 | |||||
<< ToByteVector(pubkeys[0].GetID()) << OP_EQUALVERIFY << OP_CHECKSIG; | |||||
BOOST_CHECK(!Solver(s, whichType, solutions)); | |||||
BOOST_CHECK_EQUAL(whichType, TX_NONSTANDARD); | |||||
BOOST_CHECK_EQUAL(solutions.size(), 0); | |||||
s.clear(); | |||||
s << OP_HASH160 << OP_PUSHDATA1 << ToByteVector(CScriptID(redeemScript)) | |||||
<< OP_EQUAL; | |||||
BOOST_CHECK(!Solver(s, whichType, solutions)); | |||||
BOOST_CHECK_EQUAL(whichType, TX_NONSTANDARD); | |||||
BOOST_CHECK_EQUAL(solutions.size(), 0); | |||||
s.clear(); | |||||
s << OP_1 << OP_PUSHDATA1 << ToByteVector(pubkeys[0]) | |||||
<< ToByteVector(pubkeys[1]) << OP_2 << OP_CHECKMULTISIG; | |||||
BOOST_CHECK(!Solver(s, whichType, solutions)); | |||||
BOOST_CHECK_EQUAL(whichType, TX_NONSTANDARD); | |||||
BOOST_CHECK_EQUAL(solutions.size(), 0); | |||||
// Non-minimal pushes in OP_RETURN scripts are standard (some OP_RETURN | |||||
// protocols like SLP rely on this). Also it turns out OP_RESERVED gets past | |||||
// IsPushOnly and thus is standard here. | |||||
std::vector<uint8_t> op_return_nonminimal{ | |||||
OP_RETURN, OP_RESERVED, OP_PUSHDATA1, 0x00, 0x01, 0x01, | |||||
OP_PUSHDATA4, 0x01, 0x00, 0x00, 0x00, 0xaa}; | |||||
s.assign(op_return_nonminimal.begin(), op_return_nonminimal.end()); | |||||
BOOST_CHECK(Solver(s, whichType, solutions)); | |||||
BOOST_CHECK_EQUAL(whichType, TX_NULL_DATA); | |||||
BOOST_CHECK_EQUAL(solutions.size(), 0); | |||||
} | } | ||||
BOOST_AUTO_TEST_CASE(script_standard_Solver_failure) { | BOOST_AUTO_TEST_CASE(script_standard_Solver_failure) { | ||||
CKey key; | CKey key; | ||||
CPubKey pubkey; | CPubKey pubkey; | ||||
key.MakeNewKey(true); | key.MakeNewKey(true); | ||||
pubkey = key.GetPubKey(); | pubkey = key.GetPubKey(); | ||||
▲ Show 20 Lines • Show All 432 Lines • Show Last 20 Lines |
nit: each set of tests should be commented to make it clear which script type is intended to be tested.