From 04b2714fbbc4a019d23743a488b9f9b42652617b Mon Sep 17 00:00:00 2001 From: Greg Sanders Date: Fri, 13 Sep 2024 10:27:15 -0400 Subject: [PATCH] functional test: Add new -dustrelayfee=0 test case This test would catch regressions where ephemeral dust checks are being erroneously applied on outputs that are not actually dust. --- test/functional/mempool_dust.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/functional/mempool_dust.py b/test/functional/mempool_dust.py index 1ea03a8a9ec..bc9a12fb603 100755 --- a/test/functional/mempool_dust.py +++ b/test/functional/mempool_dust.py @@ -71,9 +71,39 @@ class DustRelayFeeTest(BitcoinTestFramework): # finally send the transaction to avoid running out of MiniWallet UTXOs self.wallet.sendrawtransaction(from_node=node, tx_hex=tx_good_hex) + def test_dustrelay(self): + self.log.info("Test that small outputs are acceptable when dust relay rate is set to 0 that would otherwise trigger ephemeral dust rules") + + self.restart_node(0, extra_args=["-dustrelayfee=0"]) + + assert_equal(self.nodes[0].getrawmempool(), []) + + # Double dust, both unspent, with fees. Would have failed individual checks. + # Dust is 1 satoshi create_self_transfer_multi disallows 0 + dusty_tx = self.wallet.create_self_transfer_multi(fee_per_output=1000, amount_per_output=1, num_outputs=2) + dust_txid = self.nodes[0].sendrawtransaction(hexstring=dusty_tx["hex"], maxfeerate=0) + + assert_equal(self.nodes[0].getrawmempool(), [dust_txid]) + + # Spends one dust along with fee input, leave other dust unspent to check ephemeral dust checks aren't being enforced + sweep_tx = self.wallet.create_self_transfer_multi(utxos_to_spend=[self.wallet.get_utxo(), dusty_tx["new_utxos"][0]]) + sweep_txid = self.nodes[0].sendrawtransaction(sweep_tx["hex"]) + + mempool_entries = self.nodes[0].getrawmempool() + assert dust_txid in mempool_entries + assert sweep_txid in mempool_entries + assert_equal(len(mempool_entries), 2) + + # Wipe extra arg to reset dust relay + self.restart_node(0, extra_args=[]) + + assert_equal(self.nodes[0].getrawmempool(), []) + def run_test(self): self.wallet = MiniWallet(self.nodes[0]) + self.test_dustrelay() + # prepare output scripts of each standard type _, uncompressed_pubkey = generate_keypair(compressed=False) _, pubkey = generate_keypair(compressed=True)