mirror of
https://github.com/ElementsProject/lightning.git
synced 2026-08-20 13:27:36 +02:00
pytest: fix races now connecting is slightly slower.
We asserted that a node would be connected, but now we always call the
chanbackup peer_connected hook, it might not be that fast:
```
2025-05-17T08:37:58.7193306Z def test_funding_fail(node_factory, bitcoind):
...
2025-05-17T08:37:58.7204037Z # Restart l2 without ridiculous locktime.
2025-05-17T08:37:58.7204546Z del l2.daemon.opts['watchtime-blocks']
2025-05-17T08:37:58.7204990Z l2.restart()
2025-05-17T08:37:58.7206578Z l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
2025-05-17T08:37:58.7207072Z
2025-05-17T08:37:58.7207522Z # We don't have enough left to cover fees if we try to spend it all.
2025-05-17T08:37:58.7208203Z with pytest.raises(RpcError, match=r'not afford'):
2025-05-17T08:37:58.7208761Z l1.rpc.fundchannel(l2.info['id'], funds)
2025-05-17T08:37:58.7209203Z
2025-05-17T08:37:58.7209598Z # Should still be connected (we didn't contact the peer)
2025-05-17T08:37:58.7210243Z assert only_one(l1.rpc.listpeers()['peers'])['connected']
2025-05-17T08:37:58.7210875Z l2.daemon.wait_for_log('Handed peer, entering loop')
2025-05-17T08:37:58.7211439Z > assert only_one(l2.rpc.listpeers()['peers'])['connected']
2025-05-17T08:37:58.7211912Z E assert False
```
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
b15100d03a
commit
f68feaeb37
1 changed files with 3 additions and 4 deletions
|
|
@ -30,9 +30,9 @@ def test_connect_basic(node_factory):
|
|||
l1id = l1.info['id']
|
||||
l2id = l2.info['id']
|
||||
|
||||
# These should be in openingd.
|
||||
# These should be in connectd.
|
||||
assert l1.rpc.getpeer(l2id)['connected']
|
||||
assert l2.rpc.getpeer(l1id)['connected']
|
||||
wait_for(lambda: l2.rpc.getpeer(l1id)['connected'])
|
||||
assert len(l1.rpc.listpeerchannels(l2id)['channels']) == 0
|
||||
assert len(l2.rpc.listpeerchannels(l1id)['channels']) == 0
|
||||
|
||||
|
|
@ -1145,6 +1145,7 @@ def test_funding_fail(node_factory, bitcoind):
|
|||
del l2.daemon.opts['watchtime-blocks']
|
||||
l2.restart()
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
wait_for(lambda: [p['connected'] for p in l2.rpc.listpeers()['peers']] == [True])
|
||||
|
||||
# We don't have enough left to cover fees if we try to spend it all.
|
||||
with pytest.raises(RpcError, match=r'not afford'):
|
||||
|
|
@ -1152,8 +1153,6 @@ def test_funding_fail(node_factory, bitcoind):
|
|||
|
||||
# Should still be connected (we didn't contact the peer)
|
||||
assert only_one(l1.rpc.listpeers()['peers'])['connected']
|
||||
l2.daemon.wait_for_log('Handed peer, entering loop')
|
||||
assert only_one(l2.rpc.listpeers()['peers'])['connected']
|
||||
|
||||
# This works.
|
||||
l1.rpc.fundchannel(l2.info['id'], int(funds / 10))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue