core-lightning/tests/plugins/broken.py
Rusty Russell f4f6279b17 pytest: thoroughly test plugin death during startup.
We modify broken.py to be able to fail at different points,
and test that during startup.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-09-17 10:24:01 -07:00

29 lines
637 B
Python
Executable File

#!/usr/bin/env python3
"""Simple plugin to test that lightningd doesnt crash if it starts a
misbehaving plugin via RPC.
"""
from pyln.client import Plugin
import os
plugin = Plugin()
crash_at = os.environ.get("BROKEN_CRASH", "before_start")
@plugin.init()
def init(options, configuration, plugin):
plugin.log("broken.py initializing {}".format(configuration))
assert crash_at == "during_init"
plugin.does_not_exist()
@plugin.method("test_broken")
def test_broken():
return {}
if crash_at == "before_start":
assert False
elif crash_at == "during_getmanifest":
del plugin.methods['getmanifest']
plugin.run()