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

Function test_write

tests/fuzz/fuzz-connectd-handshake-act3.c:30–55  ·  view source on GitHub ↗

The io_write() interceptor. * * This should be called once when the initiator is writing out its Act 1 * packet and once when the responder is writing out its Act 2 packet. */

Source from the content-addressed store, hash-verified

28 * This should be called once when the initiator is writing out its Act 1
29 * packet and once when the responder is writing out its Act 2 packet. */
30static struct io_plan *
31test_write(struct io_conn *conn, const void *data, size_t len,
32 struct io_plan *(*next)(struct io_conn *, struct handshake *),
33 struct handshake *h)
34{
35 ++write_count;
36 if (write_count == 1) {
37 /* Initiator is sending the Act 1 packet. Save it for the
38 * responder and then error out. */
39 assert(h->side == INITIATOR);
40 assert(len == sizeof(act_one));
41 memcpy(act_one, data, sizeof(act_one));
42
43 return handshake_failed(conn, h);
44 }
45 if (write_count == 2) {
46 /* Responder is sending the Act 2 packet. Check that it is
47 * initialized and discard it. */
48 assert(h->side == RESPONDER);
49 assert(len == ACT_TWO_SIZE);
50 memcheck(data, len);
51
52 return next(conn, h);
53 }
54 assert(false && "too many calls to io_write()");
55}
56
57/* The io_read() interceptor.
58 *

Callers

nothing calls this directly

Calls 1

nextFunction · 0.85

Tested by

no test coverage detected