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 = <pyln.testing.utils.NodeFactory object at 0x7f5d51743b10>
bitcoind = <pyln.testing.utils.BitcoinD object at 0x7f5d51699d10>

    @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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-07-27 13:55:10 +09:30
parent 79a76a96f7
commit 1c26ebdb31

View File

@ -3358,12 +3358,11 @@ def test_wumbo_channels(node_factory, bitcoind):
# Connect l3, get gossip. # Connect l3, get gossip.
l3.rpc.connect(l1.info['id'], 'localhost', port=l1.port) 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. # Make sure channel capacity is what we expected (might need to wait for
assert ([c['amount_msat'] for c in l3.rpc.listchannels()['channels']] # both channel updates!
== [Millisatoshi(str(1 << 24) + "sat")] * 2) 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 # Make sure channel features are right from channel_announcement
assert ([c['features'] for c in l3.rpc.listchannels()['channels']] assert ([c['features'] for c in l3.rpc.listchannels()['channels']]