mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
Test IsPushOnly() with invalid push
This commit is contained in:
parent
41abb02122
commit
aa41ac216e
@ -1874,9 +1874,11 @@ bool CScript::IsPushOnly() const
|
|||||||
const_iterator pc = begin();
|
const_iterator pc = begin();
|
||||||
while (pc < end())
|
while (pc < end())
|
||||||
{
|
{
|
||||||
|
// Note how a script with an invalid PUSHDATA returns False.
|
||||||
opcodetype opcode;
|
opcodetype opcode;
|
||||||
if (!GetOp(pc, opcode))
|
if (!GetOp(pc, opcode))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Note that IsPushOnly() *does* consider OP_RESERVED to be a
|
// Note that IsPushOnly() *does* consider OP_RESERVED to be a
|
||||||
// push-type opcode, however execution of OP_RESERVED fails, so
|
// push-type opcode, however execution of OP_RESERVED fails, so
|
||||||
// it's not relevant to P2SH as the scriptSig would fail prior to
|
// it's not relevant to P2SH as the scriptSig would fail prior to
|
||||||
|
@ -394,4 +394,15 @@ BOOST_AUTO_TEST_CASE(script_standard_push)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 unsigned char direct[] = { 1 };
|
||||||
|
BOOST_CHECK(!CScript(direct, direct+sizeof(direct)).IsPushOnly());
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
Loading…
Reference in New Issue
Block a user