Skip to content

Commit f92e750

Browse files
author
MarcoFalke
committed
Merge #17480: test: add unit test for non-standard txs with too large scriptSig
5e8a563 test: add unit test for non-standard txs with too large scriptSig (Sebastian Falbesoner) Pull request description: Approaches the first missing test of issue #17394: Checks that the function `IsStandardTx()` returns rejection reason `"scriptsig-size"` if any one the inputs' scriptSig is larger than 1650 bytes. ACKs for top commit: MarcoFalke: ACK 5e8a563 instagibbs: ACK bitcoin/bitcoin@5e8a563 Tree-SHA512: 79977b12ddea9438a37cefdbb48cc551e4ad02a8ccfaa2d2837ced9f3a185e2e07cc366c243b9e3c7736245e90e315d7b4110efc6b440c63dbef7ee2c9d78a73
2 parents 422ec33 + 5e8a563 commit f92e750

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/test/transaction_tests.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,19 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
784784
reason.clear();
785785
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
786786
BOOST_CHECK_EQUAL(reason, "multi-op-return");
787+
788+
// Check large scriptSig (non-standard if size is >1650 bytes)
789+
t.vout.resize(1);
790+
t.vout[0].nValue = MAX_MONEY;
791+
t.vout[0].scriptPubKey = GetScriptForDestination(PKHash(key.GetPubKey()));
792+
// OP_PUSHDATA2 with len (3 bytes) + data (1647 bytes) = 1650 bytes
793+
t.vin[0].scriptSig = CScript() << std::vector<unsigned char>(1647, 0); // 1650
794+
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
795+
796+
t.vin[0].scriptSig = CScript() << std::vector<unsigned char>(1648, 0); // 1651
797+
reason.clear();
798+
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
799+
BOOST_CHECK_EQUAL(reason, "scriptsig-size");
787800
}
788801

789802
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)