Skip to content

Commit 65750ff

Browse files
committed
pytest: add test for closing feerate greater than final commit tx.
This is now allowed for anchors (as per lightning/bolts#847). We need to play with feerates, since we don't put a discount on anchor commitments yet. Signed-off-by: Rusty Russell <[email protected]>
1 parent 5be061c commit 65750ff

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

tests/test_closing.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from utils import (
77
only_one, sync_blockheight, wait_for, TIMEOUT,
88
account_balance, first_channel_id, closing_fee, TEST_NETWORK,
9-
scriptpubkey_addr
9+
scriptpubkey_addr, EXPERIMENTAL_FEATURES
1010
)
1111

1212
import os
@@ -2742,6 +2742,43 @@ def test_shutdown_alternate_txid(node_factory, bitcoind):
27422742
wait_for(lambda: l1.rpc.listpeers()['peers'] == [])
27432743

27442744

2745+
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "Needs anchor_outputs")
2746+
@pytest.mark.developer("needs to set dev-disconnect")
2747+
def test_closing_higherfee(node_factory, bitcoind, executor):
2748+
"""With anchor outputs we can ask for a *higher* fee than the last commit tx"""
2749+
2750+
# We change the feerate before it starts negotiating close, so it aims
2751+
# for *higher* than last commit tx.
2752+
l1, l2 = node_factory.line_graph(2, opts=[{'may_reconnect': True,
2753+
'dev-no-reconnect': None,
2754+
'feerates': (7500, 7500, 7500, 7500),
2755+
'disconnect': ['-WIRE_CLOSING_SIGNED']},
2756+
{'may_reconnect': True,
2757+
'dev-no-reconnect': None,
2758+
'feerates': (7500, 7500, 7500, 7500)}])
2759+
# This will trigger disconnect.
2760+
fut = executor.submit(l1.rpc.close, l2.info['id'])
2761+
l1.daemon.wait_for_log('dev_disconnect')
2762+
2763+
# Now adjust fees so l1 asks for more on reconnect.
2764+
l1.set_feerates((30000,) * 4, False)
2765+
l2.set_feerates((30000,) * 4, False)
2766+
l1.restart()
2767+
l2.restart()
2768+
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
2769+
2770+
# This causes us to *exceed* previous requirements!
2771+
l1.daemon.wait_for_log(r'deriving max fee from rate 30000 -> 16440sat \(not 8430sat\)')
2772+
2773+
# This will fail because l1 restarted!
2774+
with pytest.raises(RpcError, match=r'Connection to RPC server lost.'):
2775+
fut.result(TIMEOUT)
2776+
2777+
# But we still complete negotiation!
2778+
wait_for(lambda: only_one(l1.rpc.listpeers()['peers'])['channels'][0]['state'] == 'CLOSINGD_COMPLETE')
2779+
wait_for(lambda: only_one(l2.rpc.listpeers()['peers'])['channels'][0]['state'] == 'CLOSINGD_COMPLETE')
2780+
2781+
27452782
@pytest.mark.developer("needs dev_disconnect")
27462783
def test_htlc_rexmit_while_closing(node_factory, executor):
27472784
"""Retranmitting an HTLC revocation while shutting down should work"""

0 commit comments

Comments
 (0)