mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +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:
parent
1e4f85a539
commit
006ab1e367
2 changed files with 13 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
from pyln.client import Plugin
|
||||
import os
|
||||
import time
|
||||
|
||||
plugin = Plugin()
|
||||
|
@ -8,7 +9,7 @@ plugin = Plugin()
|
|||
@plugin.init()
|
||||
def init(options, configuration, plugin):
|
||||
plugin.log("slow_init.py initializing {}".format(configuration))
|
||||
time.sleep(21)
|
||||
time.sleep(int(os.getenv('SLOWINIT_TIME', "0")))
|
||||
|
||||
|
||||
plugin.run()
|
||||
|
|
|
@ -194,6 +194,7 @@ def test_plugin_dir(node_factory):
|
|||
|
||||
def test_plugin_slowinit(node_factory):
|
||||
"""Tests that the 'plugin' RPC command times out if plugin doesnt respond"""
|
||||
os.environ['SLOWINIT_TIME'] = '21'
|
||||
n = node_factory.get_node()
|
||||
|
||||
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()
|
||||
|
||||
|
||||
@pytest.mark.xfail(strict=True)
|
||||
def test_plugin_command(node_factory):
|
||||
"""Tests the 'plugin' RPC command"""
|
||||
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."):
|
||||
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):
|
||||
"""--disable-plugin works"""
|
||||
|
|
Loading…
Add table
Reference in a new issue