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

Function run

tests/fuzz/fuzz-open_channel.c:440–480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

438}
439
440void run(const u8 *data, size_t size)
441{
442 if (setjmp(fuzz_env) != 0)
443 goto cleanup;
444
445 /* The function under test: fundee_channel(), calls
446 * clean_tmpctx() mid-run, so create a separate context.
447 */
448 const tal_t *run_ctx = tal(NULL, tal_t);
449
450 /* Initialize the global pointers to the fuzz data. */
451 cursor = &data;
452 max = &size;
453
454 state = fromwire_new_state(run_ctx);
455 if (!state)
456 goto cleanup;
457
458 u8 *open_channel_msg;
459 /* Choose between creating a valid message and a fuzzed one. */
460 if (fromwire_u8(cursor, max) % 2)
461 open_channel_msg = create_open_channel_msg(run_ctx, state);
462 else {
463 u8 *fuzz_msg = create_fuzz_msg(run_ctx);
464
465 open_channel_msg = tal_arr(run_ctx, u8, 0);
466 towire_u16(&open_channel_msg, WIRE_OPEN_CHANNEL);
467 towire_u8_array(&open_channel_msg, fuzz_msg, tal_bytelen(fuzz_msg));
468 }
469
470 if (!open_channel_msg)
471 goto cleanup;
472
473 hsmd_reads = hsmd_writes = ld_writes = 0;
474 /* We received an `open_channel` msg, so we're the fundee. */
475 fundee_channel(state, open_channel_msg);
476
477cleanup:
478 tal_free(run_ctx);
479 clean_tmpctx();
480}

Callers

nothing calls this directly

Calls 10

fromwire_new_stateFunction · 0.85
create_open_channel_msgFunction · 0.85
create_fuzz_msgFunction · 0.85
tal_bytelenFunction · 0.85
fundee_channelFunction · 0.85
tal_freeFunction · 0.85
clean_tmpctxFunction · 0.85
fromwire_u8Function · 0.50
towire_u16Function · 0.50
towire_u8_arrayFunction · 0.50

Tested by

no test coverage detected