pytest: test (failing) for not crashing if plugin fails to exec via plugin startdir

It hits the new assert(): before that (tested!) it actually kills everything and logs you out.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-08-16 16:57:20 +09:30
parent 55168e66ad
commit bc36a4580c
2 changed files with 22 additions and 0 deletions

15
tests/plugins/badinterp.py Executable file
View file

@ -0,0 +1,15 @@
#!/some/bad/path/to/python3
from pyln.client import Plugin
import os
import time
plugin = Plugin()
@plugin.init()
def init(options, configuration, plugin):
plugin.log("slow_init.py initializing {}".format(configuration))
time.sleep(int(os.getenv('SLOWINIT_TIME', "0")))
plugin.run()

View file

@ -4273,3 +4273,10 @@ def test_renepay_not_important(node_factory):
# But we don't shut down, and we can restrart.
assert [p['name'] for p in l1.rpc.listconfigs()['plugins'] if p['name'] == 'cln-renepay'] == []
l1.rpc.plugin_start(os.path.join(os.getcwd(), 'plugins/cln-renepay'))
@pytest.mark.xfail(strict=True)
def test_plugin_startdir_lol(node_factory):
"""Though we fail to start many of them, we don't crash!"""
l1 = node_factory.get_node(allow_broken_log=True)
l1.rpc.plugin_startdir(os.path.join(os.getcwd(), 'tests/plugins'))