Browse Source

rpc: check error now consistent with lightning-cli

We now return JSONRPC2_METHOD_NOT_FOUND if the command is not found,
just like lightning-cli does.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
plugin-6
Mark Beckwith 6 years ago
committed by Christian Decker
parent
commit
816840e9c4
  1. 6
      lightningd/jsonrpc.c
  2. 2
      tests/test_misc.py

6
lightningd/jsonrpc.c

@ -970,9 +970,9 @@ static bool json_tok_command(struct command *cmd, const char *name,
if (cmd->json_cmd) if (cmd->json_cmd)
return (*out = tok); return (*out = tok);
command_fail(cmd, JSONRPC2_INVALID_PARAMS, command_fail(cmd, JSONRPC2_METHOD_NOT_FOUND,
"'%s' of '%.*s' is invalid", "Unknown command '%.*s'",
name, tok->end - tok->start, buffer + tok->start); tok->end - tok->start, buffer + tok->start);
return false; return false;
} }

2
tests/test_misc.py

@ -1079,7 +1079,7 @@ def test_check_command(node_factory):
l1.rpc.check(command_to_check='help', command='check') l1.rpc.check(command_to_check='help', command='check')
# Note: this just checks form, not whether it's valid! # Note: this just checks form, not whether it's valid!
l1.rpc.check(command_to_check='help', command='badcommand') l1.rpc.check(command_to_check='help', command='badcommand')
with pytest.raises(RpcError, match=r'is invalid'): with pytest.raises(RpcError, match=r'Unknown command'):
l1.rpc.check(command_to_check='badcommand') l1.rpc.check(command_to_check='badcommand')
with pytest.raises(RpcError, match=r'unknown parameter'): with pytest.raises(RpcError, match=r'unknown parameter'):
l1.rpc.check(command_to_check='help', badarg='x') l1.rpc.check(command_to_check='help', badarg='x')

Loading…
Cancel
Save