mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-04 03:03:51 +01:00
pytest: fix flake in test_onchain_different_fees
Sometimes, we haven't reconnected, and so the peer does not exist at all after the channel is forgotten: ``` 2022-09-22T22:49:59.3985374Z # Now, 100 blocks it should be done. 2022-09-22T22:49:59.3985656Z bitcoind.generate_block(100) 2022-09-22T22:49:59.3986112Z > wait_for(lambda: only_one(l1.rpc.listpeers()['peers'])['channels'] == []) 2022-09-22T22:49:59.3986338Z 2022-09-22T22:49:59.3986523Z tests/test_closing.py:2715: 2022-09-22T22:49:59.3986810Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2022-09-22T22:49:59.3987241Z contrib/pyln-testing/pyln/testing/utils.py:90: in wait_for 2022-09-22T22:49:59.3987568Z while not success(): 2022-09-22T22:49:59.3987917Z tests/test_closing.py:2715: in <lambda> 2022-09-22T22:49:59.3988389Z wait_for(lambda: only_one(l1.rpc.listpeers()['peers'])['channels'] == []) 2022-09-22T22:49:59.3988737Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 2022-09-22T22:49:59.3988908Z 2022-09-22T22:49:59.3988979Z arr = [] 2022-09-22T22:49:59.3989106Z 2022-09-22T22:49:59.3989209Z def only_one(arr): 2022-09-22T22:49:59.3989545Z """Many JSON RPC calls return an array; often we only expect a single entry 2022-09-22T22:49:59.3989849Z """ 2022-09-22T22:49:59.3990063Z > assert len(arr) == 1 2022-09-22T22:49:59.3990388Z E AssertionError ``` You can see it's empty from the call here: ``` 2022-09-22T22:49:59.6697941Z DEBUG:root:{ 2022-09-22T22:49:59.6698106Z "id": "-c:listpeers#42", 2022-09-22T22:49:59.6698179Z "result": { 2022-09-22T22:49:59.6698270Z "peers": [] 2022-09-22T22:49:59.6698346Z } 2022-09-22T22:49:59.6698422Z } ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
9b5bc81541
commit
57002f3381
1 changed files with 4 additions and 2 deletions
|
@ -2712,8 +2712,10 @@ def test_onchain_different_fees(node_factory, bitcoind, executor):
|
|||
|
||||
# Now, 100 blocks it should be done.
|
||||
bitcoind.generate_block(100)
|
||||
wait_for(lambda: only_one(l1.rpc.listpeers()['peers'])['channels'] == [])
|
||||
wait_for(lambda: only_one(l2.rpc.listpeers()['peers'])['channels'] == [])
|
||||
|
||||
# May reconnect, may not: if not, peer does not exist!
|
||||
wait_for(lambda: all(p['channels'] == [] for p in l1.rpc.listpeers()['peers']))
|
||||
wait_for(lambda: all(p['channels'] == [] for p in l2.rpc.listpeers()['peers']))
|
||||
|
||||
|
||||
@pytest.mark.developer("needs DEVELOPER=1")
|
||||
|
|
Loading…
Add table
Reference in a new issue