From 6384cadd696cce243305be944b6225f8c464ebff Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Mon, 18 Jan 2021 16:04:51 +0100 Subject: [PATCH] pytest: Stabilize the negotiation tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We also make the logic a bit nicer to read. The failure was due to more than one status message being present if we look at the wrong time: ``` arr = ['CLOSINGD_SIGEXCHANGE:We agreed on a closing fee of 20334 satoshi for tx:17f1e9d377840edf79d8b6f1ed0faba59bb307463461...9b98', 'CLOSINGD_SIGEXCHANGE:Waiting for another closing fee offer: ours was 20334 satoshi, theirs was 20332 satoshi,'] │ def only_one(arr): """Many JSON RPC calls return an array; often we only expect a single entry """ > assert len(arr) == 1 E AssertionError ``` --- tests/test_closing.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_closing.py b/tests/test_closing.py index 4dc84aa8f..998fc6e14 100644 --- a/tests/test_closing.py +++ b/tests/test_closing.py @@ -415,10 +415,14 @@ def closing_negotiation_step(node_factory, bitcoind, chainparams, opts): def get_fee_from_status(node, peer_id, i): nonlocal fees_from_status - status = only_one(only_one(node.rpc.listpeers(peer_id)['peers'][0]['channels'])['status']) + peer = only_one(node.rpc.listpeers(peer_id)['peers']) + channel = only_one(peer['channels']) + status = channel['status'][0] + m = status_agreed_regex.search(status) if not m: return False + fees_from_status[i] = int(m.group(1)) return True