Skip to content

Commit 54b12e4

Browse files
author
MarcoFalke
committed
Merge #17555: test: add unit test for non-standard txs with wrong nVersion
76303f6 test: add unit test for non-standard txs with wrong nVersion (Dominik Spicher) Pull request description: Takes care of one of the missing cases of #17394: nVersion must be within the allowed range. ACKs for top commit: instagibbs: ACK bitcoin/bitcoin@76303f6 Tree-SHA512: 94464f781cf70a5616f7cea2014ae0a97a338c34411cc989c60389de2ce00368374811db78c919bda30e0ebf341fb830998a5e97c124dd8afc8feb726cedfd3a
2 parents 1fdaa04 + 76303f6 commit 54b12e4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/test/transaction_tests.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,29 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
713713
t.vout[0].nValue = nDustThreshold;
714714
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
715715

716+
// Disallowed nVersion
717+
t.nVersion = -1;
718+
reason.clear();
719+
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
720+
BOOST_CHECK_EQUAL(reason, "version");
721+
722+
t.nVersion = 0;
723+
reason.clear();
724+
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
725+
BOOST_CHECK_EQUAL(reason, "version");
726+
727+
t.nVersion = 3;
728+
reason.clear();
729+
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
730+
BOOST_CHECK_EQUAL(reason, "version");
731+
732+
// Allowed nVersion
733+
t.nVersion = 1;
734+
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
735+
736+
t.nVersion = 2;
737+
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
738+
716739
// Check dust with odd relay fee to verify rounding:
717740
// nDustThreshold = 182 * 3702 / 1000
718741
dustRelayFee = CFeeRate(3702);

0 commit comments

Comments
 (0)