mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
pytest: fix test_ping_timeout flake.
We can hang up due to ping while waiting for channel to become active.
But we don't even need an active channel for this test, so simplify.
```
______________________________ test_ping_timeout _______________________________
[gw1] linux -- Python 3.7.13 /opt/hostedtoolcache/Python/3.7.13/x64/bin/python3
node_factory = <pyln.testing.utils.NodeFactory object at 0x7f132cca8a90>
@pytest.mark.developer("dev-disconnect required")
def test_ping_timeout(node_factory):
# Disconnects after this, but doesn't know it.
l1_disconnects = ['xWIRE_PING']
l1, l2 = node_factory.line_graph(2, opts=[{'dev-no-reconnect': None,
'disconnect': l1_disconnects},
> {}])
tests/test_connection.py:3826:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
contrib/pyln-testing/pyln/testing/utils.py:1493: in line_graph
self.join_nodes(nodes, fundchannel, fundamount, wait_for_announce, announce_channels)
contrib/pyln-testing/pyln/testing/utils.py:1470: in join_nodes
nodes[i].wait_channel_active(scids[i])
contrib/pyln-testing/pyln/testing/utils.py:1003: in wait_channel_active
wait_for(lambda: self.is_channel_active(chanid))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
success = <function LightningNode.wait_channel_active.<locals>.<lambda> at 0x7f132c3ef830>
timeout = 900
def wait_for(success, timeout=TIMEOUT):
start_time = time.time()
interval = 0.25
while not success():
time_left = start_time + timeout - time.time()
if time_left <= 0:
> raise ValueError("Timeout while waiting for {}", success)
E ValueError: ('Timeout while waiting for {}', <function LightningNode.wait_channel_active.<locals>.<lambda> at 0x7f132c3ef830>)
```
This commit is contained in:
@@ -3841,12 +3841,15 @@ def test_ping_timeout(node_factory):
|
||||
# Disconnects after this, but doesn't know it.
|
||||
l1_disconnects = ['xWIRE_PING']
|
||||
|
||||
l1, l2 = node_factory.line_graph(2, opts=[{'dev-no-reconnect': None,
|
||||
'disconnect': l1_disconnects},
|
||||
{}])
|
||||
l1, l2 = node_factory.get_nodes(2, opts=[{'dev-no-reconnect': None,
|
||||
'disconnect': l1_disconnects},
|
||||
{}])
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
|
||||
# Takes 15-45 seconds, then another to try second ping
|
||||
# Because of ping timer randomness we don't know which side hangs up first
|
||||
wait_for(lambda: l1.rpc.getpeer(l2.info['id'])['connected'] is False, timeout=45 + 45 + 5)
|
||||
wait_for(lambda: l1.rpc.listpeers(l2.info['id'])['peers'] == [],
|
||||
timeout=45 + 45 + 5)
|
||||
wait_for(lambda: (l1.daemon.is_in_log('Last ping unreturned: hanging up')
|
||||
or l2.daemon.is_in_log('Last ping unreturned: hanging up')))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user