Skip to content

Commit 3a2f1a3

Browse files
tests: add regression test for #8902 dual-fund disconnect BROKEN
Add test_inflight_dbload which triggers a disconnect at +WIRE_COMMITMENT_SIGNED during a dual-funded lease open. Before the fix in the previous commit, the disconnect notification race would cause a spurious 'Plugin must return a psbt with signatures' BROKEN log. Now only the expected 'dualopend daemon died' BROKEN appears.
1 parent f54441f commit 3a2f1a3

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

tests/test_opening.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2993,3 +2993,45 @@ def test_zeroconf_withhold_htlc_failback(node_factory, bitcoind):
29932993

29942994
# l1's channel to l2 is still normal — no force-close
29952995
assert only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['state'] == 'CHANNELD_NORMAL'
2996+
2997+
2998+
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
2999+
@pytest.mark.openchannel('v2')
3000+
def test_inflight_dbload(node_factory, bitcoind):
3001+
"""Disconnect during dual-fund sign should not trigger spurious BROKEN.
3002+
3003+
Regression test for #8902: when the peer disconnects while the
3004+
openchannel2_sign hook is being processed, the funder plugin's
3005+
disconnect notification races with the hook, causing it to return
3006+
the PSBT unsigned. Before the fix, this produced a spurious
3007+
'Plugin must return a psbt with signatures' BROKEN message.
3008+
"""
3009+
disconnects = ["+WIRE_COMMITMENT_SIGNED"]
3010+
3011+
opts = [{'experimental-dual-fund': None, 'dev-no-reconnect': None,
3012+
'may_reconnect': True, 'disconnect': disconnects},
3013+
{'experimental-dual-fund': None, 'dev-no-reconnect': None,
3014+
'may_reconnect': True, 'funder-policy': 'match',
3015+
'funder-policy-mod': 100, 'lease-fee-base-sat': '100sat',
3016+
'lease-fee-basis': 100,
3017+
# The daemon-death BROKEN is expected on disconnect
3018+
'broken_log': 'dualopend daemon died before signed PSBT returned'}]
3019+
3020+
l1, l2 = node_factory.get_nodes(2, opts=opts)
3021+
3022+
feerate = 2000
3023+
amount = 500000
3024+
l1.fundwallet(20000000)
3025+
l2.fundwallet(20000000)
3026+
3027+
# l1 leases a channel from l2
3028+
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3029+
rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount)
3030+
l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount,
3031+
feerate='{}perkw'.format(feerate),
3032+
compact_lease=rates['compact_lease'])
3033+
l1.daemon.wait_for_log(r'dev_disconnect: \+WIRE_COMMITMENT_SIGNED')
3034+
3035+
# Restart l1; before the fix this would leave a spurious BROKEN
3036+
# 'Plugin must return a psbt with signatures' in l2's log.
3037+
l1.restart()

0 commit comments

Comments
 (0)