From 1a5916cb819dd6aa3481a181d0ad3c51a0839bf9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 18 Nov 2024 17:08:58 +1030 Subject: [PATCH] pytest: try to fix flake in test_lightningd_still_loading I can't reproduce this, but CI did (with Elements): ``` [gw3] linux -- Python 3.8.18 /home/runner/.cache/pypoetry/virtualenvs/cln-meta-project-AqJ9wMix-py3.8/bin/python node_factory = bitcoind = executor = @pytest.mark.openchannel('v1') @pytest.mark.openchannel('v2') def test_lightningd_still_loading(node_factory, bitcoind, executor): """Test that we recognize we haven't got all blocks from bitcoind""" mock_release = Event() # This is slow enough that we're going to notice. def mock_getblock(r): conf_file = os.path.join(bitcoind.bitcoin_dir, 'bitcoin.conf') brpc = RawProxy(btc_conf_file=conf_file) if r['params'][0] == slow_blockid: mock_release.wait(TIMEOUT) return { "result": brpc._call(r['method'], *r['params']), "error": None, "id": r['id'] } # Start it, establish channel, get extra funds. l1, l2, l3 = node_factory.get_nodes(3, opts=[{'may_reconnect': True, 'wait_for_bitcoind_sync': False}, {'may_reconnect': True, 'wait_for_bitcoind_sync': False}, {}]) node_factory.join_nodes([l1, l2]) # Balance l1<->l2 channel l1.pay(l2, 10**9 // 2) l1.stop() # Now make sure l2 is behind. bitcoind.generate_block(2) # Make sure l2/l3 are synced sync_blockheight(bitcoind, [l2, l3]) # Make it slow grabbing the final block. slow_blockid = bitcoind.rpc.getblockhash(bitcoind.rpc.getblockcount()) l1.daemon.rpcproxy.mock_rpc('getblock', mock_getblock) l1.start(wait_for_bitcoind_sync=False) # It will warn about being out-of-sync. assert 'warning_bitcoind_sync' not in l1.rpc.getinfo() assert 'warning_lightningd_sync' in l1.rpc.getinfo() # Make sure it's connected to l2 (otherwise we get TEMPORARY_CHANNEL_FAILURE) wait_for(lambda: only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['connected']) # Payments will succced. l1.pay(l2, 1000) > assert l1.daemon.is_in_log(r"Sending HTLC while still syncing with bitcoin network \(104 vs 105\)") E AssertionError: assert None E + where None = >('Sending HTLC while still syncing with bitcoin network \\(104 vs 105\\)') E + where > = .is_in_log E + where = .daemon ``` What was in logs was: ``` lightningd-1 2024-11-18T05:33:50.634Z DEBUG 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-chan#1: Sending HTLC while still syncing with bitcoin network (103 vs 105) ``` Implying that l1 was an extra block behind. Signed-off-by: Rusty Russell --- tests/test_misc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_misc.py b/tests/test_misc.py index 280c7207c..0e16f337f 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -283,6 +283,7 @@ def test_lightningd_still_loading(node_factory, bitcoind, executor): # Make sure it's connected to l2 (otherwise we get TEMPORARY_CHANNEL_FAILURE) wait_for(lambda: only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['connected']) + wait_for(lambda: l1.rpc.getinfo()['blockheight'] == 104) # Payments will succced. l1.pay(l2, 1000)