Skip to content

Commit

Permalink
pytest: fix flake in test_upgrade_statickey_onchaind
Browse files Browse the repository at this point in the history
We need to make sure l1 has closed previous channel:

```
wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')

tests/test_connection.py:3866: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
contrib/pyln-testing/pyln/testing/utils.py:88: in wait_for
    while not success():
tests/test_connection.py:3866: in <lambda>
    wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['state'] == 'CHANNELD_NORMAL')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

arr = [{'alias': {'local': '7000028x5013088x54781', 'remote': '3360520x6431919x56666'}, 'channel_id': 'fb198b27b1be882937eea...: ['static_remotekey/even']}, 'close_to': '5120888ab14b6e1655d1d00039b836d70b66e3351543ab6cd2f94166255f3d5e6cb5', ...}]

    def only_one(arr):
        """Many JSON RPC calls return an array; often we only expect a single entry
        """
>       assert len(arr) == 1
E       AssertionError
```

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Jan 31, 2024
1 parent 8454e49 commit d2e7831
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3785,6 +3785,7 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):

bitcoind.generate_block(100, wait_for_mempool=txid)
# This works even if they disconnect and listpeerchannels() is empty:
wait_for(lambda: l1.rpc.listpeerchannels()['channels'] == [])
wait_for(lambda: l2.rpc.listpeerchannels()['channels'] == [])

# TEST 2: Cheat from post-upgrade.
Expand Down Expand Up @@ -3817,6 +3818,7 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):

bitcoind.generate_block(100, wait_for_mempool=txid)
# This works even if they disconnect and listpeers() is empty:
wait_for(lambda: len(l1.rpc.listpeerchannels()['channels']) == 0)
wait_for(lambda: len(l2.rpc.listpeerchannels()['channels']) == 0)

# TEST 3: Unilateral close from pre-upgrade
Expand Down Expand Up @@ -3852,6 +3854,7 @@ def test_upgrade_statickey_onchaind(node_factory, executor, bitcoind):
bitcoind.generate_block(100, wait_for_mempool=txid)

# This works even if they disconnect and listpeerchannels() is empty:
wait_for(lambda: len(l1.rpc.listpeerchannels()['channels']) == 0)
wait_for(lambda: len(l2.rpc.listpeerchannels()['channels']) == 0)

# TEST 4: Unilateral close from post-upgrade
Expand Down

0 comments on commit d2e7831

Please sign in to comment.