From 9d8b3a070b7b0e6d408a9a05d733426a4d37d7f1 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 10 Aug 2018 12:38:17 +0930 Subject: [PATCH] pytest: make test_htlc_send_timeout more reliable. Waiting for three node_announcments isn't always enough, since l2 can publish two of them (an independent bug). Do the more Right Thing and just wait for 30 seconds of no input... Signed-off-by: Rusty Russell --- tests/test_misc.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/test_misc.py b/tests/test_misc.py index c09b796db..fee552e74 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -799,13 +799,15 @@ def test_htlc_send_timeout(node_factory, bitcoind): # Make sure channels get announced. bitcoind.generate_block(5) - # Last thing each node receives is the three NODE_ANNOUNCEMENTS. - l1.daemon.wait_for_logs(['\[IN\] 0101'] * 3) - l2.daemon.wait_for_logs(['\[IN\] 0101'] * 3) + # Make sure we have 30 seconds without any incoming traffic from l3 to l2 + # so it tries to ping before sending WIRE_COMMITMENT_SIGNED. + timedout = False + while not timedout: + try: + l2.daemon.wait_for_log('channeld-{} chan #[0-9]*:\[IN\] 0101'.format(l3.info['id']), timeout=30) + except TimeoutError: + timedout = True - # Now need to wait have 30 seconds with no traffic to l1, so it - # tries to ping before sending WIRE_COMMITMENT_SIGNED. - time.sleep(30) inv = l3.rpc.invoice(123000, 'test_htlc_send_timeout', 'description') with pytest.raises(RpcError) as excinfo: l1.rpc.pay(inv['bolt11']) @@ -818,11 +820,6 @@ def test_htlc_send_timeout(node_factory, bitcoind): assert only_one(err.error['data']['failures'])['erring_node'] == l2.info['id'] assert only_one(err.error['data']['failures'])['erring_channel'] == chanid2 - # L1 should send a ping beforehand, and get reply, then send commitment. - l1.daemon.wait_for_log('channeld.*:\[OUT\] 0012') - l1.daemon.wait_for_log('channeld.*:\[IN\] 0013') - l1.daemon.wait_for_log('channeld.*:\[OUT\] 0084') - # L2 should send ping, but never receive pong so never send commitment. l2.daemon.wait_for_log('channeld.*:\[OUT\] 0012') assert not l2.daemon.is_in_log('channeld.*:\[IN\] 0013')