mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
tests: add plugin for simple invoice delay.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
b48c644e7a
commit
380c044668
2 changed files with 29 additions and 1 deletions
18
tests/plugins/hold_invoice.py
Executable file
18
tests/plugins/hold_invoice.py
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Simple plugin to allow testing while closing of HTLC is delayed.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from lightning import Plugin
|
||||||
|
import time
|
||||||
|
|
||||||
|
plugin = Plugin()
|
||||||
|
|
||||||
|
|
||||||
|
@plugin.hook('invoice_payment')
|
||||||
|
def on_payment(payment, plugin):
|
||||||
|
time.sleep(float(plugin.get_option('holdtime')))
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
plugin.add_option('holdtime', '10', 'The time to hold invoice for.')
|
||||||
|
plugin.run()
|
|
@ -2,7 +2,7 @@ from collections import OrderedDict
|
||||||
from fixtures import * # noqa: F401,F403
|
from fixtures import * # noqa: F401,F403
|
||||||
from flaky import flaky # noqa: F401
|
from flaky import flaky # noqa: F401
|
||||||
from lightning import RpcError, Millisatoshi
|
from lightning import RpcError, Millisatoshi
|
||||||
from utils import only_one, wait_for
|
from utils import only_one, wait_for, TIMEOUT
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -293,6 +293,16 @@ def test_invoice_payment_hook(node_factory):
|
||||||
l2.daemon.wait_for_log('preimage=' + '0' * 64)
|
l2.daemon.wait_for_log('preimage=' + '0' * 64)
|
||||||
|
|
||||||
|
|
||||||
|
def test_invoice_payment_hook_hold(node_factory):
|
||||||
|
""" l1 uses the hold_invoice plugin to delay invoice payment.
|
||||||
|
"""
|
||||||
|
opts = [{}, {'plugin': 'tests/plugins/hold_invoice.py', 'holdtime': TIMEOUT / 2}]
|
||||||
|
l1, l2 = node_factory.line_graph(2, opts=opts)
|
||||||
|
|
||||||
|
inv1 = l2.rpc.invoice(123000, 'label', 'description', preimage='1' * 64)
|
||||||
|
l1.rpc.pay(inv1['bolt11'])
|
||||||
|
|
||||||
|
|
||||||
def test_openchannel_hook(node_factory, bitcoind):
|
def test_openchannel_hook(node_factory, bitcoind):
|
||||||
""" l2 uses the reject_odd_funding_amounts plugin to reject some openings.
|
""" l2 uses the reject_odd_funding_amounts plugin to reject some openings.
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Reference in a new issue