From bf9cdc597e5996696b74c75b1fdc1be2f5ec7bcf Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 29 Jan 2024 10:11:39 +1030 Subject: [PATCH] pytest: fix flake in test_custommsg_triggers_notification If listpeers on l2 is called too fast, then it won't return any peers, and we will fail: ``` # Connect l1 to l2 l1.connect(l2) > wait_for(lambda: l2.rpc.listpeers(l1.info['id'])['peers'][0]['connected']) tests/test_misc.py:2690: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ contrib/pyln-testing/pyln/testing/utils.py:88: in wait_for while not success(): _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > wait_for(lambda: l2.rpc.listpeers(l1.info['id'])['peers'][0]['connected']) E IndexError: list index out of range ``` Signed-off-by: Rusty Russell --- tests/test_misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_misc.py b/tests/test_misc.py index 851dd7eec..887004652 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -2687,7 +2687,7 @@ def test_custommsg_triggers_notification(node_factory): # Connect l1 to l2 l1.connect(l2) - wait_for(lambda: l2.rpc.listpeers(l1.info['id'])['peers'][0]['connected']) + wait_for(lambda: [p['connected'] for p in l2.rpc.listpeers(l1.info['id'])['peers']] == [True]) # Send a custommsg from l2 to l1 # The message id 7777 is chosen to be sufficiently high and shouldn't be used by the