mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-06 21:57:54 +02:00
Merge bitcoin/bitcoin#34919: test: script: boundary at exactly 65535 bytes must use OP_PUSHDATA2
f899674639test: script: boundary at exactly 65535 bytes must use OP_PUSHDATA2 (Bruno Garcia) Pull request description: I noticed that the following mutant is not killed by any current test (can be tested with: `cmake --build build -j $(nproc) && ./build/bin/test_bitcoin && ./build/test/functional/test_runner.py -j $(nproc) -F`): ```diff diff --git a/src/script/script.cpp b/src/script/script.cpp index 3f764aaf21..5cff51d2cf 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -387,7 +387,7 @@ bool CheckMinimalPush(const std::vector<unsigned char>& data, opcodetype opcode) } else if (data.size() <= 255) { // Must have used OP_PUSHDATA. return opcode == OP_PUSHDATA1; - } else if (data.size() <= 65535) { + } else if (data.size() < 65535) { // Must have used OP_PUSHDATA2. return opcode == OP_PUSHDATA2; } ``` This PR addresses it by adding a new test case to ensure that the boundary at exactly 65535 bytes must use OP_PUSHDATA2 as well. ACKs for top commit: kevkevinpal: tACK [f899674](f899674639) danielabrozzoni: tACKf899674639darosior: utACKf899674639w0xlt: ACKf899674639Tree-SHA512: ad35cc992aa351d26151cb79d1b1d5d960b1d80a98b3076a709aa19f7b5135edb87a957d2c84f359e86da8a15f7f0196301bfaff5ae554aecc65d81c97f8af3e
This commit is contained in:
@@ -1455,6 +1455,14 @@ BOOST_AUTO_TEST_CASE(script_IsPushOnly_on_invalid_scripts)
|
||||
BOOST_CHECK(!CScript(direct, direct+sizeof(direct)).IsPushOnly());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(script_CheckMinimalPush_boundary)
|
||||
{
|
||||
// Test the boundary at exactly 65535 bytes: must use OP_PUSHDATA2, not OP_PUSHDATA4.
|
||||
std::vector<unsigned char> data(65535, '\x42');
|
||||
BOOST_CHECK(CheckMinimalPush(data, OP_PUSHDATA2));
|
||||
BOOST_CHECK(!CheckMinimalPush(data, OP_PUSHDATA4));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(script_GetScriptAsm)
|
||||
{
|
||||
BOOST_CHECK_EQUAL("OP_CHECKLOCKTIMEVERIFY", ScriptToAsmStr(CScript() << OP_NOP2, true));
|
||||
|
||||
Reference in New Issue
Block a user