From 0cba0623188fa07bdb76e251ef74e2a849e47259 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 22 Mar 2022 19:24:13 +1030 Subject: [PATCH] pytest: add test to check we notice remote disconnects. Signed-off-by: Rusty Russell --- tests/test_connection.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/test_connection.py b/tests/test_connection.py index 23aaabafe..0af389818 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -401,8 +401,19 @@ def test_disconnect_opener(node_factory): l1.rpc.fundchannel(l2.info['id'], 25000) # Should still only have one peer! - assert len(l1.rpc.listpeers()) == 1 - assert len(l2.rpc.listpeers()) == 1 + assert len(l1.rpc.listpeers()['peers']) == 1 + assert len(l2.rpc.listpeers()['peers']) == 1 + + +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'] != [] + l2.rpc.disconnect(l1.info['id']) + + # l1 should notice! + wait_for(lambda: l1.rpc.listpeers()['peers'] == []) @pytest.mark.developer