pytest: Add a test for htlc_accepted hook replay on startup

This commit is contained in:
Christian Decker
2019-05-21 14:16:00 +02:00
committed by Rusty Russell
parent 6db1e76156
commit dd26a01c54
2 changed files with 62 additions and 0 deletions

27
tests/plugins/hold_htlcs.py Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env python3
"""Plugin that holds on to HTLCs for 10 seconds.
Used to test restarts / crashes while HTLCs were accepted, but not yet
settled/forwarded/
"""
from lightning import Plugin
import time
plugin = Plugin()
@plugin.hook("htlc_accepted")
def on_htlc_accepted(htlc, onion, plugin):
plugin.log("Holding onto an incoming htlc for 10 seconds")
time.sleep(10)
# Give the tester something to look for
plugin.log("htlc_accepted hook called")
return {'result': 'continue'}
plugin.run()