mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
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 <lambda>
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 <rusty@rustcorp.com.au>
This commit is contained in:
@@ -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']])
|
||||
|
||||
Reference in New Issue
Block a user