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>
This commit is contained in:
Mark Beckwith 2018-12-07 11:11:19 -06:00 committed by Christian Decker
parent 001e215064
commit 816840e9c4
2 changed files with 4 additions and 4 deletions

View File

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

View File

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