MCPcopy Create free account
hub / github.com/ElementsProject/lightning / main

Function main

tests/plugins/test_selfdisable_after_getmanifest.c:12–42  ·  view source on GitHub ↗

Our normal frameworks don't (yet?) support custom post-manifest responses, * so this is open-coded */

Source from the content-addressed store, hash-verified

10/* Our normal frameworks don't (yet?) support custom post-manifest responses,
11 * so this is open-coded */
12int main(int argc, char *argv[])
13{
14 char *buf;
15 int r, off;
16 const jsmntok_t *toks, *id;
17
18 common_setup(argv[0]);
19
20 buf = tal_arr(tmpctx, char, 100);
21 off = 0;
22 do {
23 r = read(STDIN_FILENO, buf + off, tal_bytelen(buf) - off);
24 if (r < 0)
25 err(1, "reading stdin");
26 off += r;
27 if (off == tal_bytelen(buf))
28 tal_resize(&buf, off * 2);
29
30 toks = json_parse_simple(tmpctx, buf, off);
31 } while (!toks);
32
33 /* Tell it we're disabled (reusing id). */
34 id = json_get_member(buf, toks, "id");
35 buf = tal_fmt(tmpctx, "{\"jsonrpc\":\"2.0\",\"id\":%.*s,\"result\":{\"disable\":\"Self-disable test after getmanifest\"} }",
36 json_tok_full_len(id),
37 json_tok_full(buf, id));
38 write_all(STDOUT_FILENO, buf, strlen(buf));
39
40 common_shutdown();
41 return 0;
42}

Callers

nothing calls this directly

Calls 9

common_setupFunction · 0.85
tal_bytelenFunction · 0.85
errFunction · 0.85
common_shutdownFunction · 0.85
json_parse_simpleFunction · 0.50
json_get_memberFunction · 0.50
json_tok_full_lenFunction · 0.50
json_tok_fullFunction · 0.50
write_allFunction · 0.50

Tested by

no test coverage detected