mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
pytest: test loading all plugins at once, including failing ones.
We modify the slow_init() so it doesn't go too slowly for this test. This demonstrates a crash, where we currently try to fail a command multiple times. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from pyln.client import Plugin
|
from pyln.client import Plugin
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
plugin = Plugin()
|
plugin = Plugin()
|
||||||
@@ -8,7 +9,7 @@ plugin = Plugin()
|
|||||||
@plugin.init()
|
@plugin.init()
|
||||||
def init(options, configuration, plugin):
|
def init(options, configuration, plugin):
|
||||||
plugin.log("slow_init.py initializing {}".format(configuration))
|
plugin.log("slow_init.py initializing {}".format(configuration))
|
||||||
time.sleep(21)
|
time.sleep(int(os.getenv('SLOWINIT_TIME', "0")))
|
||||||
|
|
||||||
|
|
||||||
plugin.run()
|
plugin.run()
|
||||||
|
|||||||
@@ -194,6 +194,7 @@ def test_plugin_dir(node_factory):
|
|||||||
|
|
||||||
def test_plugin_slowinit(node_factory):
|
def test_plugin_slowinit(node_factory):
|
||||||
"""Tests that the 'plugin' RPC command times out if plugin doesnt respond"""
|
"""Tests that the 'plugin' RPC command times out if plugin doesnt respond"""
|
||||||
|
os.environ['SLOWINIT_TIME'] = '21'
|
||||||
n = node_factory.get_node()
|
n = node_factory.get_node()
|
||||||
|
|
||||||
with pytest.raises(RpcError, match="Timed out while waiting for plugin response"):
|
with pytest.raises(RpcError, match="Timed out while waiting for plugin response"):
|
||||||
@@ -205,6 +206,7 @@ def test_plugin_slowinit(node_factory):
|
|||||||
n.rpc.plugin_list()
|
n.rpc.plugin_list()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.xfail(strict=True)
|
||||||
def test_plugin_command(node_factory):
|
def test_plugin_command(node_factory):
|
||||||
"""Tests the 'plugin' RPC command"""
|
"""Tests the 'plugin' RPC command"""
|
||||||
n = node_factory.get_node()
|
n = node_factory.get_node()
|
||||||
@@ -259,6 +261,15 @@ def test_plugin_command(node_factory):
|
|||||||
with pytest.raises(RpcError, match=r"Plugin exited before completing handshake."):
|
with pytest.raises(RpcError, match=r"Plugin exited before completing handshake."):
|
||||||
n2.rpc.plugin_start(plugin=os.path.join(os.getcwd(), "tests/plugins/broken.py"))
|
n2.rpc.plugin_start(plugin=os.path.join(os.getcwd(), "tests/plugins/broken.py"))
|
||||||
|
|
||||||
|
# Test that we can add a directory with more than one new plugin in it.
|
||||||
|
try:
|
||||||
|
n.rpc.plugin_startdir(os.path.join(os.getcwd(), "tests/plugins"))
|
||||||
|
except RpcError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Usually, it crashes after the above return.
|
||||||
|
n.rpc.stop()
|
||||||
|
|
||||||
|
|
||||||
def test_plugin_disable(node_factory):
|
def test_plugin_disable(node_factory):
|
||||||
"""--disable-plugin works"""
|
"""--disable-plugin works"""
|
||||||
|
|||||||
Reference in New Issue
Block a user