| 276 | } |
| 277 | |
| 278 | static const char *init(struct command *init_cmd, |
| 279 | const char *buf UNUSED, |
| 280 | const jsmntok_t *config UNUSED) |
| 281 | { |
| 282 | const char *name, *err_str, *err_hex; |
| 283 | const u8 *binname; |
| 284 | struct plugin *p = init_cmd->plugin; |
| 285 | struct test_libplugin *tlp = get_test_libplugin(p); |
| 286 | |
| 287 | plugin_log(p, LOG_DBG, "test_libplugin initialised!"); |
| 288 | if (tlp->somearg) |
| 289 | plugin_log(p, LOG_DBG, "somearg = %s", tlp->somearg); |
| 290 | tlp->somearg = tal_free(tlp->somearg); |
| 291 | |
| 292 | for (size_t i = 0; i < tal_count(tlp->strarr); i++) { |
| 293 | plugin_log(p, LOG_DBG, "multiopt#%zu = %s", |
| 294 | i, tlp->strarr[i]); |
| 295 | } |
| 296 | if (tlp->somearg) |
| 297 | plugin_log(p, LOG_DBG, "somearg = %s", tlp->somearg); |
| 298 | |
| 299 | if (tlp->self_disable) |
| 300 | return "Disabled via selfdisable option"; |
| 301 | |
| 302 | /* Test rpc_scan_datastore funcs */ |
| 303 | err_str = rpc_scan_datastore_str(tmpctx, init_cmd, |
| 304 | mkdatastorekey(tmpctx, "test_libplugin", "name"), |
| 305 | JSON_SCAN_TAL(tmpctx, json_strdup, |
| 306 | &name)); |
| 307 | if (err_str) |
| 308 | name = NULL; |
| 309 | err_hex = rpc_scan_datastore_hex(tmpctx, init_cmd, |
| 310 | mkdatastorekey(tmpctx, "test_libplugin", "name"), |
| 311 | JSON_SCAN_TAL(tmpctx, json_tok_bin_from_hex, |
| 312 | &binname)); |
| 313 | if (err_hex) |
| 314 | binname = NULL; |
| 315 | |
| 316 | plugin_log(p, LOG_INFORM, "String name from datastore: %s", |
| 317 | name ? name : err_str); |
| 318 | plugin_log(p, LOG_INFORM, "Hex name from datastore: %s", |
| 319 | binname ? tal_hex(tmpctx, binname) : err_hex); |
| 320 | |
| 321 | return NULL; |
| 322 | } |
| 323 | |
| 324 | static const struct plugin_command commands[] = { { |
| 325 | "helloworld", |
nothing calls this directly
no test coverage detected