Skip to content

Commit 76303f6

Browse files
author
Dominik Spicher
committed
test: add unit test for non-standard txs with wrong nVersion
1 parent ae69436 commit 76303f6

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)