mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-15 20:04:24 +01:00
df-tests: test_openchannel_hook_chaining
This commit is contained in:
committed by
Christian Decker
parent
b0a8b10b41
commit
803d9701d3
@@ -373,6 +373,9 @@ openchannel2_hook_cb(struct openchannel2_payload *payload STEALS)
|
||||
tal_del_destructor2(dualopend, openchannel2_remove_dualopend, payload);
|
||||
|
||||
if (payload->err_msg) {
|
||||
log_debug(dualopend->ld->log,
|
||||
"openchannel2_hook rejects and says '%s'",
|
||||
payload->err_msg);
|
||||
msg = towire_dualopend_fail(NULL, payload->err_msg);
|
||||
return subd_send_msg(dualopend, take(msg));
|
||||
}
|
||||
|
||||
@@ -5,10 +5,14 @@ Will simply accept any channel. Useful fot testing chained hook.
|
||||
"""
|
||||
|
||||
from pyln.client import Plugin
|
||||
from pyln.testing.utils import env
|
||||
|
||||
plugin = Plugin()
|
||||
|
||||
|
||||
EXPERIMENTAL_FEATURES = env("EXPERIMENTAL_FEATURES", "0") == "1"
|
||||
|
||||
|
||||
@plugin.hook('openchannel')
|
||||
def on_openchannel(openchannel, plugin, **kwargs):
|
||||
msg = "accept on principle"
|
||||
@@ -16,4 +20,12 @@ def on_openchannel(openchannel, plugin, **kwargs):
|
||||
return {'result': 'continue'}
|
||||
|
||||
|
||||
if EXPERIMENTAL_FEATURES:
|
||||
@plugin.hook('openchannel2')
|
||||
def on_openchannel2(openchannel2, plugin, **kwargs):
|
||||
msg = "accept on principle"
|
||||
plugin.log(msg)
|
||||
return {'result': 'continue'}
|
||||
|
||||
|
||||
plugin.run()
|
||||
|
||||
@@ -6,6 +6,10 @@ Useful fot testing chained hook.
|
||||
"""
|
||||
|
||||
from pyln.client import Plugin
|
||||
from pyln.testing.utils import env
|
||||
|
||||
EXPERIMENTAL_FEATURES = env("EXPERIMENTAL_FEATURES", "0") == "1"
|
||||
|
||||
|
||||
plugin = Plugin()
|
||||
|
||||
@@ -17,4 +21,12 @@ def on_openchannel(openchannel, plugin, **kwargs):
|
||||
return {'result': 'reject', 'error_message': msg}
|
||||
|
||||
|
||||
if EXPERIMENTAL_FEATURES:
|
||||
@plugin.hook('openchannel2')
|
||||
def on_openchannel2(openchannel2, plugin, **kwargs):
|
||||
msg = "reject on principle"
|
||||
plugin.log(msg)
|
||||
return {'result': 'reject', 'error_message': msg}
|
||||
|
||||
|
||||
plugin.run()
|
||||
|
||||
@@ -646,7 +646,7 @@ def test_openchannel_hook_chaining(node_factory, bitcoind):
|
||||
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts)
|
||||
l1.fundwallet(10**6)
|
||||
|
||||
hook_msg = "openchannel_hook rejects and says '"
|
||||
hook_msg = "openchannel2?_hook rejects and says '"
|
||||
# 100005sat fundchannel should fail fatal() for l2
|
||||
# because hook_accepter.py rejects on that amount 'for a reason'
|
||||
with pytest.raises(RpcError, match=r'They sent error channel'):
|
||||
|
||||
Reference in New Issue
Block a user