pytest: Test a plugin crash while handling a hook call

This commit is contained in:
Christian Decker
2020-02-05 23:01:28 +01:00
committed by Rusty Russell
parent 7f6f324590
commit 72757933f0
2 changed files with 71 additions and 0 deletions

20
tests/plugins/hook-crash.py Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env python3
from pyln.client import Plugin
import sys
plugin = Plugin()
@plugin.hook('htlc_accepted')
def on_htlc_accepted(plugin, htlc, onion, **kwargs):
"""We die silently, i.e., without returning a response
`lightningd` should detect that and recover.
"""
plugin.log("Plugin is about to crash...")
sys.exit(1)
plugin.run()