|
37 | 37 | #include "plugins/bkpr/rebalances.c" |
38 | 38 | #include "plugins/bkpr/sql.c" |
39 | 39 |
|
40 | | -#if HAVE_SQLITE3 |
41 | | - #include <sqlite3.h> |
42 | | -#endif |
43 | | - |
44 | 40 | /* AUTOGENERATED MOCKS START */ |
45 | 41 | /* Generated stub for chain_event_description */ |
46 | 42 | const char *chain_event_description(const struct bkpr *bkpr UNNEEDED, |
@@ -89,6 +85,55 @@ void plugin_log(struct plugin *p UNNEEDED, enum log_level l UNNEEDED, const char |
89 | 85 | { fprintf(stderr, "plugin_log called!\n"); abort(); } |
90 | 86 | /* AUTOGENERATED MOCKS END */ |
91 | 87 |
|
| 88 | +struct command_result *jsonrpc_set_datastore_(struct command *cmd UNNEEDED, |
| 89 | + const char *path UNNEEDED, |
| 90 | + const void *value UNNEEDED, |
| 91 | + int len_or_str UNNEEDED, |
| 92 | + const char *mode UNNEEDED, |
| 93 | + struct command_result *(*cb)(struct command *command, |
| 94 | + const char *method, |
| 95 | + const char *buf, |
| 96 | + const jsmntok_t *result, |
| 97 | + void *arg), |
| 98 | + struct command_result *(*errcb)(struct command *command UNNEEDED, |
| 99 | + const char *method UNNEEDED, |
| 100 | + const char *buf UNNEEDED, |
| 101 | + const jsmntok_t *result UNNEEDED, |
| 102 | + void *arg) UNNEEDED, |
| 103 | + void *arg) |
| 104 | + |
| 105 | +{ |
| 106 | + return cb(cmd, NULL, NULL, NULL, arg); |
| 107 | +} |
| 108 | + |
| 109 | +struct command_result *ignore_datastore_reply(struct command *cmd, |
| 110 | + const char *method UNNEEDED, |
| 111 | + const char *buf UNNEEDED, |
| 112 | + const jsmntok_t *result UNNEEDED, |
| 113 | + void *arg UNNEEDED) |
| 114 | +{ |
| 115 | + return NULL; |
| 116 | +} |
| 117 | + |
| 118 | +struct json_out *json_out_obj(const tal_t *ctx, |
| 119 | + const char *fieldname, |
| 120 | + const char *str) |
| 121 | +{ |
| 122 | + struct json_out *jout = json_out_new(ctx); |
| 123 | + json_out_start(jout, NULL, '{'); |
| 124 | + if (str) |
| 125 | + json_out_addstr(jout, fieldname, str); |
| 126 | + if (taken(str)) |
| 127 | + tal_free(str); |
| 128 | + json_out_end(jout, '}'); |
| 129 | + json_out_finished(jout); |
| 130 | + |
| 131 | + return jout; |
| 132 | +} |
| 133 | + |
| 134 | +#if HAVE_SQLITE3 |
| 135 | +#include <sqlite3.h> |
| 136 | + |
92 | 137 | static sqlite3 *bkpr_db; |
93 | 138 | static struct command *cmd; |
94 | 139 |
|
@@ -425,59 +470,12 @@ static void log_channel_event(sqlite3 *db, |
425 | 470 | sqlite3_finalize(stmt); |
426 | 471 | } |
427 | 472 |
|
428 | | -struct command_result *jsonrpc_set_datastore_(struct command *cmd UNNEEDED, |
429 | | - const char *path UNNEEDED, |
430 | | - const void *value UNNEEDED, |
431 | | - int len_or_str UNNEEDED, |
432 | | - const char *mode UNNEEDED, |
433 | | - struct command_result *(*cb)(struct command *command, |
434 | | - const char *method, |
435 | | - const char *buf, |
436 | | - const jsmntok_t *result, |
437 | | - void *arg), |
438 | | - struct command_result *(*errcb)(struct command *command UNNEEDED, |
439 | | - const char *method UNNEEDED, |
440 | | - const char *buf UNNEEDED, |
441 | | - const jsmntok_t *result UNNEEDED, |
442 | | - void *arg) UNNEEDED, |
443 | | - void *arg) |
444 | | - |
445 | | -{ |
446 | | - return cb(cmd, NULL, NULL, NULL, arg); |
447 | | -} |
448 | | - |
449 | | -struct command_result *ignore_datastore_reply(struct command *cmd, |
450 | | - const char *method UNNEEDED, |
451 | | - const char *buf UNNEEDED, |
452 | | - const jsmntok_t *result UNNEEDED, |
453 | | - void *arg UNNEEDED) |
454 | | -{ |
455 | | - return NULL; |
456 | | -} |
457 | | - |
458 | | -struct json_out *json_out_obj(const tal_t *ctx, |
459 | | - const char *fieldname, |
460 | | - const char *str) |
461 | | -{ |
462 | | - struct json_out *jout = json_out_new(ctx); |
463 | | - json_out_start(jout, NULL, '{'); |
464 | | - if (str) |
465 | | - json_out_addstr(jout, fieldname, str); |
466 | | - if (taken(str)) |
467 | | - tal_free(str); |
468 | | - json_out_end(jout, '}'); |
469 | | - json_out_finished(jout); |
470 | | - |
471 | | - return jout; |
472 | | -} |
473 | | - |
474 | 473 | const jsmntok_t *jsonrpc_request_sync(const tal_t *ctx, |
475 | 474 | struct command *cmd, |
476 | 475 | const char *method, |
477 | 476 | const struct json_out *params TAKES, |
478 | 477 | const char **resp) |
479 | 478 | { |
480 | | -#if HAVE_SQLITE3 |
481 | 479 | sqlite3_stmt *s; |
482 | 480 | jsmntok_t *toks; |
483 | 481 | jsmn_parser parser; |
@@ -551,9 +549,6 @@ const jsmntok_t *jsonrpc_request_sync(const tal_t *ctx, |
551 | 549 | tal_free(params); |
552 | 550 | *resp = buf; |
553 | 551 | return toks; |
554 | | -#else |
555 | | - return NULL; |
556 | | -#endif |
557 | 552 | } |
558 | 553 |
|
559 | 554 | static char *tmp_dsn(const tal_t *ctx) |
@@ -1660,21 +1655,35 @@ int main(int argc, char *argv[]) |
1660 | 1655 |
|
1661 | 1656 | common_setup(argv[0]); |
1662 | 1657 |
|
1663 | | - if (HAVE_SQLITE3) { |
1664 | | - /* UBSan insists cmd isn't NULL */ |
1665 | | - cmd = tal(tmpctx, struct command); |
1666 | | - ok &= test_account_crud(tmpctx); |
1667 | | - ok &= test_channel_event_crud(tmpctx); |
1668 | | - ok &= test_chain_event_crud(tmpctx); |
1669 | | - ok &= test_account_balances(tmpctx); |
1670 | | - ok &= test_onchain_fee_chan_close(tmpctx); |
1671 | | - ok &= test_onchain_fee_chan_open(tmpctx); |
1672 | | - ok &= test_channel_rebalances(tmpctx); |
1673 | | - ok &= test_onchain_fee_wallet_spend(tmpctx); |
1674 | | - sqlite3_close(bkpr_db); |
1675 | | - } |
| 1658 | + /* UBSan insists cmd isn't NULL */ |
| 1659 | + cmd = tal(tmpctx, struct command); |
| 1660 | + ok &= test_account_crud(tmpctx); |
| 1661 | + ok &= test_channel_event_crud(tmpctx); |
| 1662 | + ok &= test_chain_event_crud(tmpctx); |
| 1663 | + ok &= test_account_balances(tmpctx); |
| 1664 | + ok &= test_onchain_fee_chan_close(tmpctx); |
| 1665 | + ok &= test_onchain_fee_chan_open(tmpctx); |
| 1666 | + ok &= test_channel_rebalances(tmpctx); |
| 1667 | + ok &= test_onchain_fee_wallet_spend(tmpctx); |
| 1668 | + sqlite3_close(bkpr_db); |
1676 | 1669 |
|
1677 | 1670 | common_shutdown(); |
1678 | 1671 | trace_cleanup(); |
1679 | 1672 | return !ok; |
1680 | 1673 | } |
| 1674 | +#else /* No sqlite, no test! */ |
| 1675 | +const jsmntok_t *jsonrpc_request_sync(const tal_t *ctx, |
| 1676 | + struct command *cmd, |
| 1677 | + const char *method, |
| 1678 | + const struct json_out *params TAKES, |
| 1679 | + const char **resp) |
| 1680 | +{ |
| 1681 | + abort(); |
| 1682 | +} |
| 1683 | + |
| 1684 | +int main(int argc, char *argv[]) |
| 1685 | +{ |
| 1686 | + common_setup(argv[0]); |
| 1687 | + common_shutdown(); |
| 1688 | +} |
| 1689 | +#endif /* !HAVE_SQLITE3 */ |
0 commit comments