Skip to content

Commit 04b2714

Browse files
committed
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.
1 parent 2b33322 commit 04b2714

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/functional/mempool_dust.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,39 @@ def test_dust_output(self, node: TestNode, dust_relay_fee: Decimal,
7171
# finally send the transaction to avoid running out of MiniWallet UTXOs
7272
self.wallet.sendrawtransaction(from_node=node, tx_hex=tx_good_hex)
7373

74+
def test_dustrelay(self):
75+
self.log.info("Test that small outputs are acceptable when dust relay rate is set to 0 that would otherwise trigger ephemeral dust rules")
76+
77+
self.restart_node(0, extra_args=["-dustrelayfee=0"])
78+
79+
assert_equal(self.nodes[0].getrawmempool(), [])
80+
81+
# Double dust, both unspent, with fees. Would have failed individual checks.
82+
# Dust is 1 satoshi create_self_transfer_multi disallows 0
83+
dusty_tx = self.wallet.create_self_transfer_multi(fee_per_output=1000, amount_per_output=1, num_outputs=2)
84+
dust_txid = self.nodes[0].sendrawtransaction(hexstring=dusty_tx["hex"], maxfeerate=0)
85+
86+
assert_equal(self.nodes[0].getrawmempool(), [dust_txid])
87+
88+
# Spends one dust along with fee input, leave other dust unspent to check ephemeral dust checks aren't being enforced
89+
sweep_tx = self.wallet.create_self_transfer_multi(utxos_to_spend=[self.wallet.get_utxo(), dusty_tx["new_utxos"][0]])
90+
sweep_txid = self.nodes[0].sendrawtransaction(sweep_tx["hex"])
91+
92+
mempool_entries = self.nodes[0].getrawmempool()
93+
assert dust_txid in mempool_entries
94+
assert sweep_txid in mempool_entries
95+
assert_equal(len(mempool_entries), 2)
96+
97+
# Wipe extra arg to reset dust relay
98+
self.restart_node(0, extra_args=[])
99+
100+
assert_equal(self.nodes[0].getrawmempool(), [])
101+
74102
def run_test(self):
75103
self.wallet = MiniWallet(self.nodes[0])
76104

105+
self.test_dustrelay()
106+
77107
# prepare output scripts of each standard type
78108
_, uncompressed_pubkey = generate_keypair(compressed=False)
79109
_, pubkey = generate_keypair(compressed=True)

0 commit comments

Comments
 (0)