mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-19 05:44:12 +01:00
pytest: test pay during channel open
Notably this parses the listpeerchannels output while the state is still uncommitted, i.e., state = OPENINGD.
This commit is contained in:
parent
dc099a046c
commit
56d5d45448
32
tests/plugins/openchannel_hook_delay.py
Executable file
32
tests/plugins/openchannel_hook_delay.py
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Plugin to test openchannel_hook
|
||||
|
||||
Will simply accept any channel. Useful fot testing chained hook.
|
||||
"""
|
||||
|
||||
from pyln.client import Plugin
|
||||
import time
|
||||
|
||||
plugin = Plugin()
|
||||
|
||||
|
||||
@plugin.hook('openchannel')
|
||||
def on_openchannel(openchannel, plugin, **kwargs):
|
||||
delaytime = float(plugin.get_option('delaytime'))
|
||||
msg = f'delaying WIRE_ACCEPT_CHANNEL for {delaytime}s'
|
||||
plugin.log(msg)
|
||||
time.sleep(delaytime)
|
||||
return {'result': 'continue'}
|
||||
|
||||
|
||||
@plugin.hook('openchannel2')
|
||||
def on_openchannel2(openchannel2, plugin, **kwargs):
|
||||
delaytime = float(plugin.get_option('delaytime'))
|
||||
msg = f'delaying WIRE_ACCEPT_CHANNEL for {delaytime}s'
|
||||
plugin.log(msg)
|
||||
time.sleep(delaytime)
|
||||
return {'result': 'continue'}
|
||||
|
||||
|
||||
plugin.add_option('delaytime', '10', 'How long to hold the WIRE_OPEN_CHANNEL.')
|
||||
plugin.run()
|
@ -5588,3 +5588,20 @@ def test_pay_partial_msat(node_factory, executor):
|
||||
|
||||
l1pay.result(TIMEOUT)
|
||||
l3pay.result(TIMEOUT)
|
||||
|
||||
|
||||
@pytest.mark.xfail(strict=True)
|
||||
def test_pay_while_opening_channel(node_factory, bitcoind, executor):
|
||||
delay_plugin = {'plugin': os.path.join(os.getcwd(),
|
||||
'tests/plugins/openchannel_hook_delay.py'),
|
||||
'delaytime': '10'}
|
||||
l1, l2 = node_factory.line_graph(2, fundamount=10**6, wait_for_announce=True)
|
||||
l3 = node_factory.get_node(options=delay_plugin)
|
||||
l1.connect(l3)
|
||||
executor.submit(l1.rpc.fundchannel, l3.info['id'], 100000)
|
||||
wait_for(lambda: l1.rpc.listpeerchannels(l3.info['id'])['channels'] != [])
|
||||
|
||||
# the uncommitted channel should now show up in listpeerchannels
|
||||
assert only_one(l1.rpc.listpeerchannels(l3.info['id'])['channels'])['state'] == 'OPENINGD'
|
||||
inv = l2.rpc.invoice(10000, "inv", "inv")
|
||||
l1.rpc.pay(inv['bolt11'])
|
||||
|
Loading…
Reference in New Issue
Block a user