commando: send id inside JSON request.

All JSON-RPC calls should have one!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-01-03 14:53:28 +10:30
parent 19db6a25e4
commit b3fa4b932e
2 changed files with 7 additions and 6 deletions

View File

@ -679,9 +679,10 @@ static struct command_result *json_commando(struct command *cmd,
tal_arr_expand(&outgoing_commands, ocmd);
tal_add_destructor2(ocmd, destroy_commando, &outgoing_commands);
/* We pass through their JSON id untouched. */
json = tal_fmt(tmpctx,
"{\"method\":\"%s\",\"params\":%s", method,
cparams ? cparams : "{}");
"{\"method\":\"%s\",\"id\":%s,\"params\":%s", method,
cmd->id, cparams ? cparams : "{}");
if (rune)
tal_append_fmt(&json, ",\"rune\":\"%s\"", rune);
tal_append_fmt(&json, "}");

View File

@ -2608,7 +2608,7 @@ def test_plugin_shutdown(node_factory):
def test_commando(node_factory, executor):
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts={'allow-deprecated-apis': True})
l1, l2 = node_factory.line_graph(2, fundchannel=False)
# Nothing works until we've issued a rune.
fut = executor.submit(l2.rpc.call, method='commando',
@ -2698,7 +2698,7 @@ def test_commando(node_factory, executor):
def test_commando_rune(node_factory):
l1, l2 = node_factory.get_nodes(2, opts={'allow-deprecated-apis': True})
l1, l2 = node_factory.get_nodes(2)
# Force l1's commando secret
l1.rpc.datastore(key=['commando', 'secret'], hex='1241faef85297127c2ac9bde95421b2c51e5218498ae4901dc670c974af4284b')
@ -2933,7 +2933,7 @@ def test_commando_rune(node_factory):
def test_commando_stress(node_factory, executor):
"""Stress test to slam commando with many large queries"""
nodes = node_factory.get_nodes(5, opts={'allow-deprecated-apis': True})
nodes = node_factory.get_nodes(5)
rune = nodes[0].rpc.commando_rune()['rune']
for n in nodes[1:]:
@ -2969,7 +2969,7 @@ def test_commando_stress(node_factory, executor):
def test_commando_badrune(node_factory):
"""Test invalid UTF-8 encodings in rune: used to make us kill the offers plugin which implements decode, as it gave bad utf8!"""
l1 = node_factory.get_node(options={'allow-deprecated-apis': True})
l1 = node_factory.get_node()
l1.rpc.decode('5zi6-ugA6hC4_XZ0R7snl5IuiQX4ugL4gm9BQKYaKUU9gCZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5Jm1ldGhvZC9saXN0ZGF0YXN0b3Jl')
rune = l1.rpc.commando_rune(restrictions="readonly")