aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-09-02 09:03:08 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-09-02 09:03:11 +0200
commit6bf706a0560df0794f9fd6550e4792e439162dc1 (patch)
treeb6ab04bbfb1027d9e8230fe0226df82a999909f8 /src
parent77e77e8544c7df5981da9795cda5f1aaa99f73af (diff)
parent97cea1a93a26d535f9bad038b559e50437ea54f7 (diff)
Merge bitcoin/bitcoin#22846: policy: unit test Segwit dust thresholds
97cea1a93a26d535f9bad038b559e50437ea54f7 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 97cea1a93a26d535f9bad038b559e50437ea54f7 benthecarman: crACK 97cea1a93a26d535f9bad038b559e50437ea54f7 Tree-SHA512: 96fb194709ae44364455eb920ed3ecff2e11e5327e0a72b9eeec9f9445894302099a0c4ffb1e0c8d4d523c0bfe06c57f1ebb0c03cf3389a73f518e3b174c45aa
Diffstat (limited to 'src')
-rw-r--r--src/test/transaction_tests.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
index 97fd0600fa..20e26d1c35 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -955,6 +955,33 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
BOOST_CHECK_EQUAL(reason, "bare-multisig");
fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
+
+ // Check P2WPKH outputs dust threshold
+ t.vout[0].scriptPubKey = CScript() << OP_0 << ParseHex("ffffffffffffffffffffffffffffffffffffffff");
+ t.vout[0].nValue = 294;
+ BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
+ t.vout[0].nValue = 293;
+ BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
+ BOOST_CHECK_EQUAL(reason, "dust");
+
+ // Check P2WSH outputs dust threshold
+ t.vout[0].scriptPubKey = CScript() << OP_0 << ParseHex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
+ t.vout[0].nValue = 330;
+ BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
+ t.vout[0].nValue = 329;
+ BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
+ BOOST_CHECK_EQUAL(reason, "dust");
+
+ // Check future Witness Program versions dust threshold
+ for (int op = OP_2; op <= OP_16; op += 1) {
+ t.vout[0].scriptPubKey = CScript() << (opcodetype)op << ParseHex("ffff");
+ t.vout[0].nValue = 240;
+ BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
+
+ t.vout[0].nValue = 239;
+ BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
+ BOOST_CHECK_EQUAL(reason, "dust");
+ }
}
BOOST_AUTO_TEST_SUITE_END()