Skip to content

Commit 6bf706a

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#22846: policy: unit test Segwit dust thresholds
97cea1a policy: unit test Segwit dust thresholds (Antoine Poinsot) Pull request description: This is the unit testing part of #22779, hence without the threshold modification. ACKs for top commit: MarcoFalke: cr ACK 97cea1a benthecarman: crACK 97cea1a Tree-SHA512: 96fb194709ae44364455eb920ed3ecff2e11e5327e0a72b9eeec9f9445894302099a0c4ffb1e0c8d4d523c0bfe06c57f1ebb0c03cf3389a73f518e3b174c45aa
2 parents 77e77e8 + 97cea1a commit 6bf706a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/test/transaction_tests.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,33 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
955955
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
956956
BOOST_CHECK_EQUAL(reason, "bare-multisig");
957957
fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
958+
959+
// Check P2WPKH outputs dust threshold
960+
t.vout[0].scriptPubKey = CScript() << OP_0 << ParseHex("ffffffffffffffffffffffffffffffffffffffff");
961+
t.vout[0].nValue = 294;
962+
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
963+
t.vout[0].nValue = 293;
964+
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
965+
BOOST_CHECK_EQUAL(reason, "dust");
966+
967+
// Check P2WSH outputs dust threshold
968+
t.vout[0].scriptPubKey = CScript() << OP_0 << ParseHex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
969+
t.vout[0].nValue = 330;
970+
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
971+
t.vout[0].nValue = 329;
972+
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
973+
BOOST_CHECK_EQUAL(reason, "dust");
974+
975+
// Check future Witness Program versions dust threshold
976+
for (int op = OP_2; op <= OP_16; op += 1) {
977+
t.vout[0].scriptPubKey = CScript() << (opcodetype)op << ParseHex("ffff");
978+
t.vout[0].nValue = 240;
979+
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
980+
981+
t.vout[0].nValue = 239;
982+
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
983+
BOOST_CHECK_EQUAL(reason, "dust");
984+
}
958985
}
959986

960987
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)