Skip to content

Commit

Permalink
Added check_fail function to run-param
Browse files Browse the repository at this point in the history
Just a utility function to check that command_fail was called.

Signed-off-by: Mark Beckwith <[email protected]>
  • Loading branch information
wythe authored and cdecker committed Jul 29, 2018
1 parent b7203b0 commit 2ca1786
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lightningd/test/run-param.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@
#include <ccan/err/err.h>
#include <unistd.h>

bool failed;
char *fail_msg;
bool failed = false;

static bool check_fail(void) {
if (!failed)
return false;
failed = false;
return true;
}

struct command *cmd;

Expand Down Expand Up @@ -82,7 +89,6 @@ static struct json *json_parse(const tal_t * ctx, const char *str)
if (ret <= 0) {
assert(0);
}
failed = false;
return j;
}

Expand Down Expand Up @@ -130,10 +136,11 @@ static void stest(const struct json *j, struct sanity *b)
if (!param(cmd, j->buffer, j->toks,
p_req("u64", json_tok_u64, &ival),
p_req("double", json_tok_double, &dval), NULL)) {
assert(failed == true);
assert(check_fail());
assert(b->failed == true);
assert(strstr(fail_msg, b->fail_str));
} else {
assert(!check_fail());
assert(b->failed == false);
assert(ival == 42);
assert(dval > 3.1499 && b->dval < 3.1501);
Expand Down

0 comments on commit 2ca1786

Please sign in to comment.