From 2a80400a0f7610f3f8aad471f526b697d25f0cd8 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 23 Mar 2022 09:31:36 +1030 Subject: [PATCH] pytest: fix test_connection.py::test_funding_close_upfront fake Breaks when there are no peers: ``` > _fundchannel(l1, l2, amt_normal, None) tests/test_connection.py:1564: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_connection.py:1535: in _fundchannel wait_for(lambda: not has_normal_channels(l2, l1)) contrib/pyln-testing/pyln/testing/utils.py:88: in wait_for while not success(): tests/test_connection.py:1535: in wait_for(lambda: not has_normal_channels(l2, l1)) tests/test_connection.py:1527: in has_normal_channels for c in only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels']]) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ arr = [] def only_one(arr): """Many JSON RPC calls return an array; often we only expect a single entry """ > assert len(arr) == 1 E AssertionError ``` Signed-off-by: Rusty Russell --- tests/test_connection.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_connection.py b/tests/test_connection.py index 9e2b284ab..2c956380a 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -1522,6 +1522,8 @@ def test_funding_close_upfront(node_factory, bitcoind): remote_valid_addr = 'bcrt1q7gtnxmlaly9vklvmfj06amfdef3rtnrdazdsvw' def has_normal_channels(l1, l2): + if l1.rpc.listpeers(l2.info['id'])['peers'] == []: + return False return any([c['state'] == 'CHANNELD_AWAITING_LOCKIN' or c['state'] == 'CHANNELD_NORMAL' for c in only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels']])