From b659fbbdf72092a7f9d9d5381d417a3c1a00c6c5 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 29 Dec 2021 14:11:15 +1030 Subject: [PATCH] pytest: further deflake test_funding_push. I also got an error under CI; it seems the sleep() was insufficient. So try adding a sleep inside the check_coin_moves, which should cover everyone. ``` acct_moves = acct_moves[number_moves:] else: > if not move_matches(m, acct_moves[0]): E IndexError: list index out of range ``` Signed-off-by: Rusty Russell --- tests/test_connection.py | 2 -- tests/utils.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/test_connection.py b/tests/test_connection.py index a7ad414a2..b50dee021 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -1077,8 +1077,6 @@ def test_funding_push(node_factory, bitcoind, chainparams): assert funds['channel_sat'] + push_sat == funds['channel_total_sat'] chanid = first_channel_id(l2, l1) - # give the file write a second - time.sleep(1) channel_mvts_1 = [ {'type': 'chain_mvt', 'credit': 16777215000, 'debit': 0, 'tags': ['channel_open', 'opener']}, {'type': 'channel_mvt', 'credit': 0, 'debit': 20000000, 'tags': ['pushed'], 'fees': '0msat'}, diff --git a/tests/utils.py b/tests/utils.py index 8766ee53f..d10fdada3 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -3,6 +3,7 @@ from pyln.testing.utils import env, only_one, wait_for, write_config, TailablePr import bitstring from pyln.client import Millisatoshi from pyln.testing.utils import EXPERIMENTAL_DUAL_FUND +import time EXPERIMENTAL_FEATURES = env("EXPERIMENTAL_FEATURES", "0") == "1" COMPAT = env("COMPAT", "1") == "1" @@ -108,6 +109,19 @@ def check_balance_snaps(n, expected_bals): def check_coin_moves(n, account_id, expected_moves, chainparams): moves = n.rpc.call('listcoinmoves_plugin')['coin_moves'] + # moves can lag; wait for a few seconds if we don't have correct number. + # then move on: we'll get details below. + expected_count = 0 + for m in enumerate(expected_moves): + if isinstance(m, list): + expected_count += len(m) + else: + expected_count += 1 + + if len(moves) != expected_count: + time.sleep(5) + moves = n.rpc.call('listcoinmoves_plugin')['coin_moves'] + node_id = n.info['id'] acct_moves = [m for m in moves if m['account_id'] == account_id] for mv in acct_moves: