mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 22:45:27 +01:00
commando: require that we have an id
field in JSON request.
We don't do this yet, so we add deprecated to those test (until next patch!). Changelog-Deprecated: plugins: `commando` JSON commands without an `id` (see doc/lightningd-rpc.7.md for how to construct a good id field). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
435f8d84dc
commit
19db6a25e4
2 changed files with 11 additions and 5 deletions
|
@ -362,7 +362,7 @@ static void try_command(struct node_id *peer,
|
|||
const u8 *msg, size_t msglen)
|
||||
{
|
||||
struct commando *incoming = tal(plugin, struct commando);
|
||||
const jsmntok_t *toks, *method, *params, *rune;
|
||||
const jsmntok_t *toks, *method, *params, *rune, *id;
|
||||
const char *buf = (const char *)msg, *failmsg;
|
||||
struct out_req *req;
|
||||
|
||||
|
@ -394,6 +394,12 @@ static void try_command(struct node_id *peer,
|
|||
return;
|
||||
}
|
||||
rune = json_get_member(buf, toks, "rune");
|
||||
id = json_get_member(buf, toks, "id");
|
||||
if (!id && !deprecated_apis) {
|
||||
commando_error(incoming, COMMANDO_ERROR_REMOTE,
|
||||
"missing id field");
|
||||
return;
|
||||
}
|
||||
|
||||
failmsg = check_rune(tmpctx, incoming, peer, buf, method, params, rune);
|
||||
if (failmsg) {
|
||||
|
|
|
@ -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)
|
||||
l1, l2 = node_factory.line_graph(2, fundchannel=False, opts={'allow-deprecated-apis': True})
|
||||
|
||||
# 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)
|
||||
l1, l2 = node_factory.get_nodes(2, opts={'allow-deprecated-apis': True})
|
||||
|
||||
# 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)
|
||||
nodes = node_factory.get_nodes(5, opts={'allow-deprecated-apis': True})
|
||||
|
||||
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()
|
||||
l1 = node_factory.get_node(options={'allow-deprecated-apis': True})
|
||||
l1.rpc.decode('5zi6-ugA6hC4_XZ0R7snl5IuiQX4ugL4gm9BQKYaKUU9gCZtZXRob2RebGlzdHxtZXRob2ReZ2V0fG1ldGhvZD1zdW1tYXJ5Jm1ldGhvZC9saXN0ZGF0YXN0b3Jl')
|
||||
rune = l1.rpc.commando_rune(restrictions="readonly")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue