#include "config.h"
#define main unused_main
int main(int argc, char *argv[]);
#include "../offers.c"
#undef main
#include <ccan/array_size/array_size.h>
#include <common/json_command.h>
#include <common/setup.h>
#include <stdio.h>
struct command_result *command_check_done(struct command *cmd)
{ fprintf(stderr, "command_check_done called!\n"); abort(); }
bool command_check_only(const struct command *cmd UNNEEDED)
{ fprintf(stderr, "command_check_only called!\n"); abort(); }
bool command_deprecated_in_ok(struct command *cmd UNNEEDED,
const char *param UNNEEDED,
const char *depr_start UNNEEDED,
const char *depr_end UNNEEDED)
{ fprintf(stderr, "command_deprecated_in_ok called!\n"); abort(); }
bool command_dev_apis(const struct command *cmd UNNEEDED)
{ fprintf(stderr, "command_dev_apis called!\n"); abort(); }
struct command_result *command_fail(struct command *cmd UNNEEDED, enum jsonrpc_errcode code UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "command_fail called!\n"); abort(); }
struct json_filter **command_filter_ptr(struct command *cmd UNNEEDED)
{ fprintf(stderr, "command_filter_ptr called!\n"); abort(); }
struct command_result *command_finished(struct command *cmd UNNEEDED, struct json_stream *response)
{ fprintf(stderr, "command_finished called!\n"); abort(); }
struct command_result *command_hook_success(struct command *cmd)
{ fprintf(stderr, "command_hook_success called!\n"); abort(); }
void command_log(struct command *cmd UNNEEDED, enum log_level level UNNEEDED,
const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "command_log called!\n"); abort(); }
struct command_result *command_param_failed(void)
{ fprintf(stderr, "command_param_failed called!\n"); abort(); }
void command_set_usage(struct command *cmd UNNEEDED, const char *usage UNNEEDED)
{ fprintf(stderr, "command_set_usage called!\n"); abort(); }
bool command_usage_only(const struct command *cmd UNNEEDED)
{ fprintf(stderr, "command_usage_only called!\n"); abort(); }
struct command_result *establish_onion_path_(struct command *cmd UNNEEDED,
struct gossmap *gossmap UNNEEDED,
const struct pubkey *local_id UNNEEDED,
const struct pubkey *dst UNNEEDED,
bool connect_disable UNNEEDED,
struct command_result *(*success)(struct command * UNNEEDED,
const struct pubkey * UNNEEDED,
void *arg) UNNEEDED,
struct command_result *(*fail)(struct command * UNNEEDED,
const char *why UNNEEDED,
void *arg) UNNEEDED,
void *arg UNNEEDED)
{ fprintf(stderr, "establish_onion_path_ called!\n"); abort(); }
bool flag_jsonfmt(struct command *cmd UNNEEDED, struct json_stream *js UNNEEDED, const char *fieldname UNNEEDED,
bool *i UNNEEDED)
{ fprintf(stderr, "flag_jsonfmt called!\n"); abort(); }
char *flag_option(struct command *cmd UNNEEDED, const char *arg UNNEEDED, bool check_only UNNEEDED, bool *i UNNEEDED)
{ fprintf(stderr, "flag_option called!\n"); abort(); }
struct command_result *forward_error(struct command *cmd UNNEEDED,
const char *method UNNEEDED,
const char *buf UNNEEDED,
const jsmntok_t *error UNNEEDED,
void *arg)
{ fprintf(stderr, "forward_error called!\n"); abort(); }
struct command_result *handle_invoice(struct command *cmd UNNEEDED,
const u8 *invbin UNNEEDED,
struct blinded_path *reply_path STEALS UNNEEDED,
const struct secret *secret UNNEEDED)
{ fprintf(stderr, "handle_invoice called!\n"); abort(); }
struct command_result *handle_invoice_onion_message(struct command *cmd UNNEEDED,
const char *buf UNNEEDED,
const jsmntok_t *om UNNEEDED,
const struct secret *pathsecret UNNEEDED)
{ fprintf(stderr, "handle_invoice_onion_message called!\n"); abort(); }
struct command_result *handle_invoice_request(struct command *cmd UNNEEDED,
const u8 *invreqbin UNNEEDED,
struct blinded_path *reply_path STEALS UNNEEDED,
const struct secret *secret TAKES UNNEEDED)
{ fprintf(stderr, "handle_invoice_request called!\n"); abort(); }
struct command_result *invoice_payment(struct command *cmd UNNEEDED,
const char *buf UNNEEDED,
const jsmntok_t *params UNNEEDED)
{ fprintf(stderr, "invoice_payment called!\n"); abort(); }
struct command_result *json_cancelrecurringinvoice(struct command *cmd UNNEEDED,
const char *buffer UNNEEDED,
const jsmntok_t *params UNNEEDED)
{ fprintf(stderr, "json_cancelrecurringinvoice called!\n"); abort(); }
struct command_result *json_dev_rawrequest(struct command *cmd UNNEEDED,
const char *buffer UNNEEDED,
const jsmntok_t *params UNNEEDED)
{ fprintf(stderr, "json_dev_rawrequest called!\n"); abort(); }
struct command_result *json_fetchinvoice(struct command *cmd UNNEEDED,
const char *buffer UNNEEDED,
const jsmntok_t *params UNNEEDED)
{ fprintf(stderr, "json_fetchinvoice called!\n"); abort(); }
struct command_result *json_invoicerequest(struct command *cmd UNNEEDED,
const char *buffer UNNEEDED,
const jsmntok_t *params UNNEEDED)
{ fprintf(stderr, "json_invoicerequest called!\n"); abort(); }
struct command_result *json_offer(struct command *cmd UNNEEDED,
const char *buffer UNNEEDED,
const jsmntok_t *params UNNEEDED)
{ fprintf(stderr, "json_offer called!\n"); abort(); }
struct json_out *json_out_obj(const tal_t *ctx UNNEEDED,
const char *fieldname UNNEEDED,
const char *str TAKES UNNEEDED)
{ fprintf(stderr, "json_out_obj called!\n"); abort(); }
struct command_result *json_sendinvoice(struct command *cmd UNNEEDED,
const char *buffer UNNEEDED,
const jsmntok_t *params UNNEEDED)
{ fprintf(stderr, "json_sendinvoice called!\n"); abort(); }
struct out_req *jsonrpc_request_start_(struct command *cmd UNNEEDED,
const char *method UNNEEDED,
const char *id_prefix UNNEEDED,
const char *filter UNNEEDED,
struct command_result *(*cb)(struct command *command UNNEEDED,
const char *methodname UNNEEDED,
const char *buf UNNEEDED,
const jsmntok_t *result UNNEEDED,
void *arg) UNNEEDED,
struct command_result *(*errcb)(struct command *command UNNEEDED,
const char *methodname UNNEEDED,
const char *buf UNNEEDED,
const jsmntok_t *result UNNEEDED,
void *arg) UNNEEDED,
void *arg)
{ fprintf(stderr, "jsonrpc_request_start_ called!\n"); abort(); }
struct json_stream *jsonrpc_stream_success(struct command *cmd)
{ fprintf(stderr, "jsonrpc_stream_success called!\n"); abort(); }
struct command_result *notification_handled(struct command *cmd)
{ fprintf(stderr, "notification_handled called!\n"); abort(); }
void plugin_err(struct plugin *p UNNEEDED, const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "plugin_err called!\n"); abort(); }
const struct feature_set *plugin_feature_set(const struct plugin *p UNNEEDED)
{ fprintf(stderr, "plugin_feature_set called!\n"); abort(); }
void *plugin_get_data_(struct plugin *plugin UNNEEDED)
{ fprintf(stderr, "plugin_get_data_ called!\n"); abort(); }
void plugin_gossmap_logcb(struct plugin *plugin UNNEEDED,
enum log_level level UNNEEDED,
const char *fmt UNNEEDED,
...)
{ fprintf(stderr, "plugin_gossmap_logcb called!\n"); abort(); }
void plugin_log(struct plugin *p UNNEEDED, enum log_level l UNNEEDED, const char *fmt UNNEEDED, ...)
{ fprintf(stderr, "plugin_log called!\n"); abort(); }
void plugin_main(char *argv[] UNNEEDED,
const char *(*init)(struct command *init_cmd UNNEEDED,
const char *buf UNNEEDED,
const jsmntok_t *) UNNEEDED,
void *data TAKES UNNEEDED,
const enum plugin_restartability restartability UNNEEDED,
bool init_rpc UNNEEDED,
struct feature_set *features STEALS UNNEEDED,
const struct plugin_command *commands TAKES UNNEEDED,
size_t num_commands UNNEEDED,
const struct plugin_notification *notif_subs TAKES UNNEEDED,
size_t num_notif_subs UNNEEDED,
const struct plugin_hook *hook_subs TAKES UNNEEDED,
size_t num_hook_subs UNNEEDED,
const char **notif_topics TAKES UNNEEDED,
size_t num_notif_topics UNNEEDED,
...)
{ fprintf(stderr, "plugin_main called!\n"); abort(); }
void rpc_scan(struct command *cmd UNNEEDED,
const char *method UNNEEDED,
const struct json_out *params TAKES UNNEEDED,
const char *guide UNNEEDED,
...)
{ fprintf(stderr, "rpc_scan called!\n"); abort(); }
struct command_result *send_outreq(const struct out_req *req UNNEEDED)
{ fprintf(stderr, "send_outreq called!\n"); abort(); }
struct likely_test {
const char *input;
enum likely_type expected;
};
static void run_likely_tests(const struct likely_test *tests)
{
for (size_t i = 0; tests[i].input; i++) {
const char *s = tests[i].input;
jsmntok_t *tok = tal(tmpctx, jsmntok_t);
tok->start = 0;
tok->end = strlen(s);
tok->type = JSMN_STRING;
assert(guess_type(s, tok) == tests[i].expected);
}
}
int main(int argc, char *argv[])
{
common_setup(argv[0]);
static const struct likely_test tests[] = {
{ "lno1qqqqqq", LIKELY_BOLT12_OFFER },
{ "LNO1QQQQQQ", LIKELY_BOLT12_OFFER },
{ "lni1abcd", LIKELY_BOLT12_INV },
{ "LNI1ABCD", LIKELY_BOLT12_INV },
{ "lnr1xyz", LIKELY_BOLT12_INVREQ },
{ "LNR1XYZ", LIKELY_BOLT12_INVREQ },
{ "clnemerg1foo", LIKELY_EMERGENCY_RECOVER },
{ "CLNEMERG1FOO", LIKELY_EMERGENCY_RECOVER },
{ "lnbc1qqqqqq", LIKELY_BOLT11 },
{ "LNBC1QQQQQQ", LIKELY_BOLT11 },
{ "lnbc10u1qqqqqq", LIKELY_BOLT11 },
{ "LNTB2500N1ABCDEF", LIKELY_BOLT11 },
{ "lnbcrt1deadbeef", LIKELY_BOLT11 },
{ "lnbcx1qqqq", LIKELY_OTHER },
{ "lnbc10x1qqqq", LIKELY_OTHER },
{ "lnbc2000qqqq", LIKELY_OTHER },
{ "notlightning", LIKELY_OTHER },
{ "", LIKELY_OTHER },
{ NULL, 0 }
};
run_likely_tests(tests);
common_shutdown();
return 0;
}