From 1a9c7783b7b638f9667d9dd8527e807486026b20 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Sun, 20 May 2018 19:39:48 -0700 Subject: [PATCH] pytest: Yet another instance where we wait only on one side Waiting on one end and then just asserting on the other is racy. Signed-off-by: Christian Decker --- tests/test_lightningd.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 76ba242e6..8466d838d 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -1584,10 +1584,14 @@ class LightningDTests(BaseLightningDTests): ['ONCHAIN:Tracking their unilateral close', 'ONCHAIN:All outputs resolved: waiting 99 more blocks before forgetting channel']) - billboard = l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]['status'] - assert len(billboard) == 2 - assert billboard[0] == 'ONCHAIN:Tracking our own unilateral close' - assert re.fullmatch('ONCHAIN:.* outputs unresolved: in 4 blocks will spend DELAYED_OUTPUT_TO_US \(.*:0\) using OUR_DELAYED_RETURN_TO_WALLET', billboard[1]) + def check_billboard(): + billboard = l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]['status'] + return ( + len(billboard) == 2 and + billboard[0] == 'ONCHAIN:Tracking our own unilateral close' and + re.fullmatch('ONCHAIN:.* outputs unresolved: in 4 blocks will spend DELAYED_OUTPUT_TO_US \(.*:0\) using OUR_DELAYED_RETURN_TO_WALLET', billboard[1]) + ) + wait_for(check_billboard) # Now, mine 4 blocks so it sends out the spending tx. bitcoind.generate_block(4)