mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 23:54:22 +01:00
connectd: hold peer until we're interested.
Either because lightningd tells us it wants to talk, or because the peer says something about a channel. We also introduce a behavior change: we disconnect after a failed open. We might want to modify this later, but we it's a side-effect of openingd not holding onto idle connections. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -3448,7 +3448,8 @@ def test_you_forgot_closed_channel(node_factory, executor):
|
||||
assert only_one(only_one(l1.rpc.listpeers()['peers'])['channels'])['state'] == 'CLOSINGD_SIGEXCHANGE'
|
||||
|
||||
# l1 reconnects, it should succeed.
|
||||
l1.rpc.disconnect(l2.info['id'], force=True)
|
||||
if only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['connected']:
|
||||
l1.rpc.disconnect(l2.info['id'], force=True)
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
fut.result(TIMEOUT)
|
||||
|
||||
|
||||
@@ -409,7 +409,7 @@ def test_remote_disconnect(node_factory):
|
||||
l1, l2 = node_factory.get_nodes(2)
|
||||
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
assert l2.rpc.listpeers()['peers'] != []
|
||||
wait_for(lambda: l2.rpc.listpeers()['peers'] != [])
|
||||
l2.rpc.disconnect(l1.info['id'])
|
||||
|
||||
# l1 should notice!
|
||||
@@ -2576,9 +2576,9 @@ def test_disconnectpeer(node_factory, bitcoind):
|
||||
wait_for(lambda: l2.rpc.getpeer(l1.info['id']) is None)
|
||||
|
||||
# Make sure you cannot disconnect after disconnecting
|
||||
with pytest.raises(RpcError, match=r'Peer not connected'):
|
||||
with pytest.raises(RpcError, match=r'Unknown peer'):
|
||||
l1.rpc.disconnect(l2.info['id'])
|
||||
with pytest.raises(RpcError, match=r'Peer not connected'):
|
||||
with pytest.raises(RpcError, match=r'Unknown peer'):
|
||||
l2.rpc.disconnect(l1.info['id'])
|
||||
|
||||
# Fund channel l1 -> l3
|
||||
|
||||
@@ -2337,6 +2337,7 @@ def test_listforwards(node_factory, bitcoind):
|
||||
assert len(c24_forwards) == 1
|
||||
|
||||
|
||||
@pytest.mark.openchannel('v1')
|
||||
def test_version_reexec(node_factory, bitcoind):
|
||||
badopeningd = os.path.join(os.path.dirname(__file__), "plugins", "badopeningd.sh")
|
||||
version = subprocess.check_output(['lightningd/lightningd',
|
||||
@@ -2358,7 +2359,12 @@ def test_version_reexec(node_factory, bitcoind):
|
||||
'fff6')) # type
|
||||
f.write(bytes('badversion\0', encoding='utf8'))
|
||||
|
||||
# Opening a channel will fire subd.
|
||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||
try:
|
||||
l1.fundchannel(l2)
|
||||
except RpcError:
|
||||
pass
|
||||
|
||||
l1.daemon.wait_for_log("openingd.*version 'badversion' not '{}': restarting".format(version))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user