v29.4-roots.1 · Commit 6: [PATCH 06/13] test: align initial Roots policy coverage
test/functional/mempool_dust.py
Before: test/functional/mempool_dust.py · After: test/functional/mempool_dust.py
File metadata
index 937e77fbd41ba47416b991c57de1056f5f0b61f0..43b84f4c7c1980ba34e00071d3abd963191a66fb 100755
Download original patch · Release notes
Diff rows 1–48 of 48. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.
test/functional/mempool_dust.py
CHANGED
|
@@ -15,7 +15,6 @@ from test_framework.script import (
|
|
| 15 |
OP_TRUE,
|
| 16 |
)
|
| 17 |
from test_framework.script_util import (
|
| 18 |
-
key_to_p2pk_script,
|
| 19 |
key_to_p2pkh_script,
|
| 20 |
key_to_p2wpkh_script,
|
| 21 |
keys_to_multisig_script,
|
|
@@ -40,7 +39,7 @@ DUST_RELAY_TX_FEE = 3000 # default setting [sat/kvB]
|
|
| 40 |
class DustRelayFeeTest(BitcoinTestFramework):
|
| 41 |
def set_test_params(self):
|
| 42 |
self.num_nodes = 1
|
| 43 |
-
self.extra_args = [['-permitbaremultisig']]
|
| 44 |
|
| 45 |
def test_dust_output(self, node: TestNode, dust_relay_fee: Decimal,
|
| 46 |
output_script: CScript, type_desc: str) -> None:
|
|
@@ -66,7 +65,7 @@ class DustRelayFeeTest(BitcoinTestFramework):
|
|
| 66 |
tx.vout[1].nValue -= 1
|
| 67 |
res = node.testmempoolaccept([tx.serialize().hex()])[0]
|
| 68 |
assert_equal(res['allowed'], False)
|
| 69 |
-
assert_equal(res['reject-reason'], 'dust')
|
| 70 |
|
| 71 |
# finally send the transaction to avoid running out of MiniWallet UTXOs
|
| 72 |
self.wallet.sendrawtransaction(from_node=node, tx_hex=tx_good_hex)
|
|
@@ -95,7 +94,7 @@ class DustRelayFeeTest(BitcoinTestFramework):
|
|
| 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 |
|
|
@@ -109,8 +108,7 @@ class DustRelayFeeTest(BitcoinTestFramework):
|
|
| 109 |
_, pubkey = generate_keypair(compressed=True)
|
| 110 |
|
| 111 |
output_scripts = (
|
| 112 |
-
(key_to_p2pk_script(uncompressed_pubkey), "P2PK (uncompressed)"),
|
| 113 |
-
(key_to_p2pk_script(pubkey), "P2PK (compressed)"),
|
| 114 |
(key_to_p2pkh_script(pubkey), "P2PKH"),
|
| 115 |
(script_to_p2sh_script(CScript([OP_TRUE])), "P2SH"),
|
| 116 |
(key_to_p2wpkh_script(pubkey), "P2WPKH"),
|
|
@@ -132,7 +130,7 @@ class DustRelayFeeTest(BitcoinTestFramework):
|
|
| 132 |
else:
|
| 133 |
dust_parameter = f"-dustrelayfee={dustfee_btc_kvb:.8f}"
|
| 134 |
self.log.info(f"Test dust limit setting {dust_parameter} ({dustfee_sat_kvb} sat/kvB)...")
|
| 135 |
-
self.restart_node(0, extra_args=[dust_parameter, "-permitbaremultisig"])
|
| 136 |
|
| 137 |
for output_script, description in output_scripts:
|
| 138 |
self.test_dust_output(self.nodes[0], dustfee_btc_kvb, output_script, description)
|
|
|
|
| 15 |
OP_TRUE,
|
| 16 |
)
|
| 17 |
from test_framework.script_util import (
|
|
|
|
| 18 |
key_to_p2pkh_script,
|
| 19 |
key_to_p2wpkh_script,
|
| 20 |
keys_to_multisig_script,
|
|
|
|
| 39 |
class DustRelayFeeTest(BitcoinTestFramework):
|
| 40 |
def set_test_params(self):
|
| 41 |
self.num_nodes = 1
|
| 42 |
+
self.extra_args = [['-permitbaremultisig=1']]
|
| 43 |
|
| 44 |
def test_dust_output(self, node: TestNode, dust_relay_fee: Decimal,
|
| 45 |
output_script: CScript, type_desc: str) -> None:
|
|
|
|
| 65 |
tx.vout[1].nValue -= 1
|
| 66 |
res = node.testmempoolaccept([tx.serialize().hex()])[0]
|
| 67 |
assert_equal(res['allowed'], False)
|
| 68 |
+
assert_equal(res['reject-reason'], 'dust-nonanchor')
|
| 69 |
|
| 70 |
# finally send the transaction to avoid running out of MiniWallet UTXOs
|
| 71 |
self.wallet.sendrawtransaction(from_node=node, tx_hex=tx_good_hex)
|
|
|
|
| 94 |
assert_equal(len(mempool_entries), 2)
|
| 95 |
|
| 96 |
# Wipe extra arg to reset dust relay
|
| 97 |
+
self.restart_node(0, extra_args=["-permitbaremultisig=1"])
|
| 98 |
|
| 99 |
assert_equal(self.nodes[0].getrawmempool(), [])
|
| 100 |
|
|
|
|
| 108 |
_, pubkey = generate_keypair(compressed=True)
|
| 109 |
|
| 110 |
output_scripts = (
|
| 111 |
+
# Roots rejects bare P2PK before dust policy is evaluated.
|
|
|
|
| 112 |
(key_to_p2pkh_script(pubkey), "P2PKH"),
|
| 113 |
(script_to_p2sh_script(CScript([OP_TRUE])), "P2SH"),
|
| 114 |
(key_to_p2wpkh_script(pubkey), "P2WPKH"),
|
|
|
|
| 130 |
else:
|
| 131 |
dust_parameter = f"-dustrelayfee={dustfee_btc_kvb:.8f}"
|
| 132 |
self.log.info(f"Test dust limit setting {dust_parameter} ({dustfee_sat_kvb} sat/kvB)...")
|
| 133 |
+
self.restart_node(0, extra_args=[dust_parameter, "-permitbaremultisig=1"])
|
| 134 |
|
| 135 |
for output_script, description in output_scripts:
|
| 136 |
self.test_dust_output(self.nodes[0], dustfee_btc_kvb, output_script, description)
|