mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 00:54:20 +01:00
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:
committed by
Christian Decker
parent
001e215064
commit
816840e9c4
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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')
|
||||||
|
|||||||
Reference in New Issue
Block a user