From 30335e1dc3938d4c0e2d75fd20be2dd9b9d6c005 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 6 Apr 2023 09:46:16 +0930 Subject: [PATCH] tests: test for stopping node while it's starting. In CI we see crashes in this case: ``` lightningd: lightningd/connect_control.c:734: void connectd_activate(struct lightningd *): Assertion `ret == ld->connectd' failed. ``` Signed-off-by: Rusty Russell --- tests/test_misc.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_misc.py b/tests/test_misc.py index c14e4815e..698a7a5ab 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -3237,3 +3237,23 @@ def test_create_gossip_mesh(node_factory, bitcoind): print("nodeids", nodeids) print("scids", scids) assert False, "Test failed on purpose, grab the gossip store from /tmp/ltests-..." + + +@pytest.mark.xfail(strict=True) +def test_fast_shutdown(node_factory): + l1 = node_factory.get_node(start=False) + + l1.daemon.start(wait_for_initialized=False) + + start_time = time.time() + # Keep trying until this succeeds (socket may not exist yet!) + while True: + if time.time() > start_time + TIMEOUT: + raise ValueError("Timeout while waiting for stop to work!") + try: + l1.rpc.stop() + except FileNotFoundError: + continue + except ConnectionRefusedError: + continue + break