Skip to content

Commit bc57dc9

Browse files
Chandra Prataprustyrussell
authored andcommitted
fuzz-tests: Make the channel_id wire test roundtrip
Changelog-None: `memcmp()` the output of `towire_channel_id()` and the input to `fromwire_channel_id()` to ensure that wire encoding-decoding is correctly performed.
1 parent 271356f commit bc57dc9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/fuzz/fuzz-channel_id.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ void run(const uint8_t *data, size_t size)
5858
for (size_t i = 0; i < tal_count(marshal_chunks); i++) {
5959
wire_ptr = marshal_chunks[i];
6060
wire_max = tal_count(marshal_chunks[i]);
61+
6162
fromwire_channel_id(&wire_ptr, &wire_max, &chan_id);
62-
wire_buf = tal_arr(NULL, uint8_t, tal_count(marshal_chunks[i]));
63+
wire_buf = tal_arr(NULL, uint8_t, 0);
6364
towire_channel_id(&wire_buf, &chan_id);
65+
assert(!memcmp(marshal_chunks[i], wire_buf, tal_count(marshal_chunks[i])));
66+
6467
tal_free(wire_buf);
6568
}
6669
tal_free(marshal_chunks);

0 commit comments

Comments
 (0)