diff --git a/tests/plugins/slow_init.py b/tests/plugins/slow_init.py new file mode 100755 index 000000000..4c5316b16 --- /dev/null +++ b/tests/plugins/slow_init.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +from lightning import Plugin +import time + +plugin = Plugin() + + +@plugin.init() +def init(options, configuration, plugin): + plugin.log("slow_init.py initializing") + time.sleep(1) + + +plugin.run() diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 42023bd44..2d1aaacc3 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -90,6 +90,20 @@ def test_plugin_dir(node_factory): node_factory.get_node(options={'plugin-dir': plugin_dir, 'greeting': 'Mars'}) +@pytest.mark.xfail(strict=True) +def test_plugin_slowinit(node_factory): + """Tests the 'plugin' RPC command when init is slow""" + n = node_factory.get_node() + + n.rpc.plugin_start(os.path.join(os.getcwd(), "tests/plugins/slow_init.py")) + n.daemon.wait_for_log("slow_init.py initializing") + + # It's not actually configured yet, see what happens; + # make sure 'rescan' and 'list' controls dont crash + n.rpc.plugin_rescan() + n.rpc.plugin_list() + + def test_plugin_command(node_factory): """Tests the 'plugin' RPC command""" n = node_factory.get_node()