Browse Source

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
```
master
Christian Decker 4 years ago
committed by Rusty Russell
parent
commit
6384cadd69
  1. 6
      tests/test_closing.py

6
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

Loading…
Cancel
Save