diff options
author | Antoine Poinsot <darosior@protonmail.com> | 2021-08-24 09:15:01 +0200 |
---|---|---|
committer | Antoine Poinsot <darosior@protonmail.com> | 2021-08-31 16:51:38 +0200 |
commit | 97cea1a93a26d535f9bad038b559e50437ea54f7 (patch) | |
tree | ea44ea0d26ea805c452b54abb69d358445a3eb42 /src/test/transaction_tests.cpp | |
parent | e9d6eb1b8071805cec1cc4e1352a13a7adc55ca8 (diff) | |
download | bitcoin-97cea1a93a26d535f9bad038b559e50437ea54f7.tar.xz |
policy: unit test Segwit dust thresholds
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
Diffstat (limited to 'src/test/transaction_tests.cpp')
-rw-r--r-- | src/test/transaction_tests.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 571f792a53..b66e826a27 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() |