From b173b2934687d076b37c888924501e3d86382bd5 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 10 Aug 2022 21:58:29 +0930 Subject: [PATCH] pytest: test loading lease_chan_max_msat from channel_funding_inflights It crashes with: ``` s32 field doesn't match size: expected 4, actual 8 ``` Reported-by: @zerofeerouting Signed-off-by: Rusty Russell --- tests/test_opening.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/test_opening.py b/tests/test_opening.py index 71da4a1f0..d4b48ed12 100644 --- a/tests/test_opening.py +++ b/tests/test_opening.py @@ -1205,6 +1205,41 @@ def test_funder_contribution_limits(node_factory, bitcoind): assert l3.daemon.is_in_log(r'calling `signpsbt` .* 7 inputs') +@pytest.mark.openchannel('v2') +@pytest.mark.developer("requres 'dev-disconnect'") +def test_inflight_dbload(node_factory, bitcoind): + """Bad db field access breaks Postgresql on startup with opening leases""" + disconnects = ["@WIRE_COMMITMENT_SIGNED"] + l1, l2 = node_factory.get_nodes(2, opts=[{'experimental-dual-fund': None, + 'dev-no-reconnect': None, + 'may_reconnect': True, + 'disconnect': disconnects}, + {'experimental-dual-fund': None, + 'dev-no-reconnect': None, + 'may_reconnect': True, + 'funder-policy': 'match', + 'funder-policy-mod': 100, + 'lease-fee-base-sat': '100sat', + 'lease-fee-basis': 100}]) + + feerate = 2000 + amount = 500000 + l1.fundwallet(20000000) + l2.fundwallet(20000000) + + # l1 leases a channel from l2 + l1.rpc.connect(l2.info['id'], 'localhost', l2.port) + rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount) + wait_for(lambda: len(l1.rpc.listpeers(l2.info['id'])['peers']) == 0) + l1.rpc.connect(l2.info['id'], 'localhost', l2.port) + l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount, + feerate='{}perkw'.format(feerate), + compact_lease=rates['compact_lease']) + l1.daemon.wait_for_log(r'dev_disconnect: @WIRE_COMMITMENT_SIGNED') + + l1.restart() + + def test_zeroconf_mindepth(bitcoind, node_factory): """Check that funder/fundee can customize mindepth.