Skip to content

Commit 924fe7a

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 cc0b841 commit 924fe7a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/test_closing.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,6 +3132,43 @@ def test_shutdown_alternate_txid(node_factory, bitcoind):
31323132
wait_for(lambda: l1.rpc.listpeers()['peers'] == [])
31333133

31343134

3135+
@unittest.skipIf(not EXPERIMENTAL_FEATURES, "Needs anchor_outputs")
3136+
@pytest.mark.developer("needs to set dev-disconnect")
3137+
def test_closing_higherfee(node_factory, bitcoind, executor):
3138+
"""With anchor outputs we can ask for a *higher* fee than the last commit tx"""
3139+
3140+
# We change the feerate before it starts negotiating close, so it aims
3141+
# for *higher* than last commit tx.
3142+
l1, l2 = node_factory.line_graph(2, opts=[{'may_reconnect': True,
3143+
'dev-no-reconnect': None,
3144+
'feerates': (7500, 7500, 7500, 7500),
3145+
'disconnect': ['-WIRE_CLOSING_SIGNED']},
3146+
{'may_reconnect': True,
3147+
'dev-no-reconnect': None,
3148+
'feerates': (7500, 7500, 7500, 7500)}])
3149+
# This will trigger disconnect.
3150+
fut = executor.submit(l1.rpc.close, l2.info['id'])
3151+
l1.daemon.wait_for_log('dev_disconnect')
3152+
3153+
# Now adjust fees so l1 asks for more on reconnect.
3154+
l1.set_feerates((30000,) * 4, False)
3155+
l2.set_feerates((30000,) * 4, False)
3156+
l1.restart()
3157+
l2.restart()
3158+
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3159+
3160+
# This causes us to *exceed* previous requirements!
3161+
l1.daemon.wait_for_log(r'deriving max fee from rate 30000 -> 16440sat \(not 1000000sat\)')
3162+
3163+
# This will fail because l1 restarted!
3164+
with pytest.raises(RpcError, match=r'Connection to RPC server lost.'):
3165+
fut.result(TIMEOUT)
3166+
3167+
# But we still complete negotiation!
3168+
wait_for(lambda: only_one(l1.rpc.listpeers()['peers'])['channels'][0]['state'] == 'CLOSINGD_COMPLETE')
3169+
wait_for(lambda: only_one(l2.rpc.listpeers()['peers'])['channels'][0]['state'] == 'CLOSINGD_COMPLETE')
3170+
3171+
31353172
@pytest.mark.developer("needs dev_disconnect")
31363173
def test_htlc_rexmit_while_closing(node_factory, executor):
31373174
"""Retranmitting an HTLC revocation while shutting down should work"""

0 commit comments

Comments
 (0)