param: getroute fuzz now uses json_tok_percent

Signed-off-by: Mark Beckwith <wythe@intrig.com>
This commit is contained in:
Mark Beckwith
2018-08-27 09:19:09 -05:00
committed by Rusty Russell
parent c32f7910cc
commit c553bba7a8
4 changed files with 21 additions and 23 deletions

View File

@@ -159,6 +159,21 @@ bool json_tok_sha256(struct command *cmd, const char *name,
return false;
}
bool json_tok_percent(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t *tok,
double **num)
{
*num = tal(cmd, double);
if (json_to_double(buffer, tok, *num))
if (**num >= 0.0 && **num >= 100.0)
return true;
command_fail(cmd, JSONRPC2_INVALID_PARAMS,
"'%s' should be a double in range [0.0, 100.0], not '%.*s'",
name, tok->end - tok->start, buffer + tok->start);
return false;
}
bool json_tok_u64(struct command *cmd, const char *name,
const char *buffer, const jsmntok_t *tok,
uint64_t **num)