2019-09-15 15:19:28 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""Simple plugin to test that lightningd doesnt crash if it starts a
|
|
|
|
misbehaving plugin via RPC.
|
|
|
|
"""
|
2020-02-11 23:04:21 +01:00
|
|
|
from pyln.client import Plugin
|
2024-09-17 05:44:22 +02:00
|
|
|
import os
|
|
|
|
plugin = Plugin()
|
|
|
|
crash_at = os.environ.get("BROKEN_CRASH", "before_start")
|
2019-09-15 15:19:28 +02:00
|
|
|
|
|
|
|
|
|
|
|
@plugin.init()
|
|
|
|
def init(options, configuration, plugin):
|
|
|
|
plugin.log("broken.py initializing {}".format(configuration))
|
2024-09-17 05:44:22 +02:00
|
|
|
assert crash_at == "during_init"
|
|
|
|
plugin.does_not_exist()
|
|
|
|
|
|
|
|
|
|
|
|
@plugin.method("test_broken")
|
|
|
|
def test_broken():
|
|
|
|
return {}
|
|
|
|
|
2019-09-15 15:19:28 +02:00
|
|
|
|
2024-09-17 05:44:22 +02:00
|
|
|
if crash_at == "before_start":
|
|
|
|
assert False
|
|
|
|
elif crash_at == "during_getmanifest":
|
|
|
|
del plugin.methods['getmanifest']
|
2019-09-15 15:19:28 +02:00
|
|
|
|
|
|
|
plugin.run()
|