Skip to content

Commit

Permalink
functional test: Add new -dustrelayfee=0 test case
Browse files Browse the repository at this point in the history
This test would catch regressions where ephemeral
dust checks are being erroneously applied on outputs
that are not actually dust.
  • Loading branch information
instagibbs committed Nov 12, 2024
1 parent 2b33322 commit 04b2714
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/functional/mempool_dust.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 71,39 @@ def test_dust_output(self, node: TestNode, dust_relay_fee: Decimal,
# 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)
Expand Down

0 comments on commit 04b2714

Please sign in to comment.