From e572b487d3655ddd21a668d8887a1995f1609d28 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 6 Dec 2019 20:04:17 +1030 Subject: [PATCH] pytest: demonstrate failing rpc_command hook rewrite to plugin. lightningd: lightningd/plugin.c:648: plugin_rpcmethod_dispatch: Assertion `idtok != NULL' failed. lightningd: FATAL SIGNAL 6 (version v0.7.3-234-gf3aeb51-modded) 0x557652363eb1 send_backtrace common/daemon.c:41 0x557652363f5b crashdump common/daemon.c:54 0x7f5b065a346f ??? ???:0 0x7f5b065a33eb ??? ???:0 0x7f5b06582898 ??? ???:0 0x7f5b06582768 ??? ???:0 0x7f5b06594005 ??? ???:0 0x557652355901 plugin_rpcmethod_dispatch lightningd/plugin.c:648 0x557652331836 command_exec lightningd/jsonrpc.c:588 0x557652331bad rpc_command_hook_callback lightningd/jsonrpc.c:655 0x557652358745 plugin_hook_callback lightningd/plugin_hook.c:90 0x55765235486a plugin_response_handle lightningd/plugin.c:258 0x557652354a16 plugin_read_json_one lightningd/plugin.c:356 0x557652354b6d plugin_read_json lightningd/plugin.c:388 0x5576523b5e6c next_plan ccan/ccan/io/io.c:59 0x5576523b6a51 do_plan ccan/ccan/io/io.c:407 0x5576523b6a93 io_ready ccan/ccan/io/io.c:417 0x5576523b8d2b io_loop ccan/ccan/io/poll.c:445 0x55765232dc6f io_loop_with_timers lightningd/io_loop_with_timers.c:24 0x557652334a6e main lightningd/lightningd.c:848 0x7f5b065841e2 ??? ???:0 0x5576523193ed ??? ???:0 0xffffffffffffffff ??? ???:0 Log dumped in crash.log.20191206093336 Signed-off-by: Rusty Russell --- tests/plugins/rpc_command.py | 3 +++ tests/test_plugin.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/tests/plugins/rpc_command.py b/tests/plugins/rpc_command.py index 506e7cb4b..dc73f3815 100755 --- a/tests/plugins/rpc_command.py +++ b/tests/plugins/rpc_command.py @@ -21,6 +21,9 @@ def on_rpc_command(plugin, rpc_command, **kwargs): # Don't allow this command to be executed return {"return": {"error": {"code": -1, "message": "You cannot do this"}}} + elif request["method"] == "help": + request["method"] = "autocleaninvoice" + return {"replace": request} return {"continue": True} diff --git a/tests/test_plugin.py b/tests/test_plugin.py index ba0634d64..a0e6e9fee 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -761,6 +761,7 @@ def test_sendpay_notifications(node_factory, bitcoind): assert results['sendpay_failure'][0] == err.value.error +@pytest.mark.xfail(strict=True) def test_rpc_command_hook(node_factory): """Test the `sensitive_command` hook""" plugin = os.path.join(os.getcwd(), "tests/plugins/rpc_command.py") @@ -779,5 +780,8 @@ def test_rpc_command_hook(node_factory): funds = l1.rpc.listfunds() assert funds[0] == "Custom result" + # Test command redirection to a plugin + l1.rpc.call('help', [0]) + # Test command which removes plugin itself! l1.rpc.plugin_stop('rpc_command.py')