From 1c26ebdb31c32cb4b853067bb262b3dca4cb150d Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 27 Jul 2022 13:55:10 +0930 Subject: [PATCH] pytest: fix flake in test_wumbo_channels We might only have seen one side of the channel, as shown below. Wait for both: ``` _____________________________ test_wumbo_channels ______________________________ [gw2] linux -- Python 3.7.13 /opt/hostedtoolcache/Python/3.7.13/x64/bin/python3 node_factory = bitcoind = @pytest.mark.openchannel('v1') @pytest.mark.openchannel('v2') def test_wumbo_channels(node_factory, bitcoind): l1, l2, l3 = node_factory.get_nodes(3, opts=[{'large-channels': None}, {'large-channels': None}, {}]) conn = l1.rpc.connect(l2.info['id'], 'localhost', port=l2.port) expected_features = expected_peer_features(wumbo_channels=True) if l1.config('experimental-dual-fund'): expected_features = expected_peer_features(wumbo_channels=True, extra=[21, 29]) assert conn['features'] == expected_features assert only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['features'] == expected_features # Now, can we open a giant channel? l1.fundwallet(1 << 26) l1.rpc.fundchannel(l2.info['id'], 1 << 24) # Get that mined, and announced. bitcoind.generate_block(6, wait_for_mempool=1) # Connect l3, get gossip. l3.rpc.connect(l1.info['id'], 'localhost', port=l1.port) wait_for(lambda: len(l3.rpc.listnodes(l1.info['id'])['nodes']) == 1) wait_for(lambda: 'features' in only_one(l3.rpc.listnodes(l1.info['id'])['nodes'])) # Make sure channel capacity is what we expected. > assert ([c['amount_msat'] for c in l3.rpc.listchannels()['channels']] == [Millisatoshi(str(1 << 24) + "sat")] * 2) E assert [16777216000msat] == [16777216000m...777216000msat] E Right contains one more item: 16777216000msat E Full diff: E - [16777216000msat, 16777216000msat] E + [16777216000msat] ``` Signed-off-by: Rusty Russell --- tests/test_connection.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/test_connection.py b/tests/test_connection.py index 8d867a8af..1dc6fbfb9 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -3358,12 +3358,11 @@ def test_wumbo_channels(node_factory, bitcoind): # Connect l3, get gossip. l3.rpc.connect(l1.info['id'], 'localhost', port=l1.port) - wait_for(lambda: len(l3.rpc.listnodes(l1.info['id'])['nodes']) == 1) - wait_for(lambda: 'features' in only_one(l3.rpc.listnodes(l1.info['id'])['nodes'])) - # Make sure channel capacity is what we expected. - assert ([c['amount_msat'] for c in l3.rpc.listchannels()['channels']] - == [Millisatoshi(str(1 << 24) + "sat")] * 2) + # Make sure channel capacity is what we expected (might need to wait for + # both channel updates! + wait_for(lambda: [c['amount_msat'] for c in l3.rpc.listchannels()['channels']] + == [Millisatoshi(str(1 << 24) + "sat")] * 2) # Make sure channel features are right from channel_announcement assert ([c['features'] for c in l3.rpc.listchannels()['channels']]