pytest: Stabilize the negotiation tests

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
```
This commit is contained in:
Christian Decker 2021-01-18 16:04:51 +01:00 committed by Rusty Russell
parent 04ed93f5f8
commit 6384cadd69

View File

@ -415,10 +415,14 @@ def closing_negotiation_step(node_factory, bitcoind, chainparams, opts):
def get_fee_from_status(node, peer_id, i): def get_fee_from_status(node, peer_id, i):
nonlocal fees_from_status 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) m = status_agreed_regex.search(status)
if not m: if not m:
return False return False
fees_from_status[i] = int(m.group(1)) fees_from_status[i] = int(m.group(1))
return True return True