mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
pytest: make sure receiving peer's openingd is ready.
There's now a potential race: the source peer connect returns, but in destination peer the master hasn't read the connect message from connectd, so the peer isn't in listpeers yet. (Previously the connection stayed in connectd, so there was no such window). This is an occasional issue in a few places. Note that we take the opportunity to speed up test_disconnectpeer too while we're there. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
50f5eb34b4
commit
e59cbb3e2c
@ -1063,6 +1063,7 @@ def test_permfail_htlc_out(node_factory, bitcoind, executor):
|
|||||||
l2 = node_factory.get_node(disconnect=disconnects)
|
l2 = node_factory.get_node(disconnect=disconnects)
|
||||||
|
|
||||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||||
|
l2.daemon.wait_for_log('openingd-{} chan #1: Handed peer, entering loop'.format(l1.info['id']))
|
||||||
l2.fund_channel(l1, 10**6)
|
l2.fund_channel(l1, 10**6)
|
||||||
|
|
||||||
# This will fail at l2's end.
|
# This will fail at l2's end.
|
||||||
|
@ -988,15 +988,14 @@ def test_disconnectpeer(node_factory, bitcoind):
|
|||||||
assert len(l1.rpc.getpeer(l2.info['id'])['channels']) == 0
|
assert len(l1.rpc.getpeer(l2.info['id'])['channels']) == 0
|
||||||
assert l1.rpc.getpeer(l3.info['id'])['connected']
|
assert l1.rpc.getpeer(l3.info['id'])['connected']
|
||||||
assert len(l1.rpc.getpeer(l3.info['id'])['channels']) == 0
|
assert len(l1.rpc.getpeer(l3.info['id'])['channels']) == 0
|
||||||
|
wait_for(lambda: l2.rpc.getpeer(l1.info['id']) is not None)
|
||||||
|
|
||||||
# Disconnect l2 from l1
|
# Disconnect l2 from l1
|
||||||
l1.rpc.disconnect(l2.info['id'])
|
l1.rpc.disconnect(l2.info['id'])
|
||||||
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
# Make sure listpeers no longer returns the disconnected node
|
# Make sure listpeers no longer returns the disconnected node
|
||||||
assert l1.rpc.getpeer(l2.info['id']) is None
|
assert l1.rpc.getpeer(l2.info['id']) is None
|
||||||
assert l2.rpc.getpeer(l1.info['id']) is None
|
wait_for(lambda: l2.rpc.getpeer(l1.info['id']) is None)
|
||||||
|
|
||||||
# Make sure you cannot disconnect after disconnecting
|
# Make sure you cannot disconnect after disconnecting
|
||||||
with pytest.raises(RpcError, match=r'Peer not connected'):
|
with pytest.raises(RpcError, match=r'Peer not connected'):
|
||||||
|
@ -348,6 +348,7 @@ def test_gossip_weirdalias(node_factory, bitcoind):
|
|||||||
.format(normal_name))
|
.format(normal_name))
|
||||||
|
|
||||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||||
|
l2.daemon.wait_for_log('openingd-{} chan #1: Handed peer, entering loop'.format(l1.info['id']))
|
||||||
l2.fund_channel(l1, 10**6)
|
l2.fund_channel(l1, 10**6)
|
||||||
bitcoind.rpc.generate(6)
|
bitcoind.rpc.generate(6)
|
||||||
|
|
||||||
|
@ -744,7 +744,11 @@ class NodeFactory(object):
|
|||||||
for src, dst in connections:
|
for src, dst in connections:
|
||||||
src.rpc.connect(dst.info['id'], 'localhost', dst.port)
|
src.rpc.connect(dst.info['id'], 'localhost', dst.port)
|
||||||
|
|
||||||
|
# If we're returning now, make sure dst all show connections in
|
||||||
|
# getpeers.
|
||||||
if not fundchannel:
|
if not fundchannel:
|
||||||
|
for src, dst in connections:
|
||||||
|
dst.daemon.wait_for_log('openingd-{} chan #[0-9]*: Handed peer, entering loop'.format(src.info['id']))
|
||||||
return nodes
|
return nodes
|
||||||
|
|
||||||
# If we got here, we want to fund channels
|
# If we got here, we want to fund channels
|
||||||
|
Loading…
Reference in New Issue
Block a user