fuzz-tests: Make the `channel_id` wire test roundtrip
What changed, and why it matters
This commit adds a consistency check inside a fuzz test for channel ID encoding and decoding. It does not change production code, fix a vulnerability, or alter any runtime behavior of the Lightning node. The change only strengthens a test to verify that converting a channel ID to wire format and back produces the original bytes.
No security action required. Treat as a normal test-quality improvement.
Security signals we found
No security-relevant code change in production paths
Change is confined to a fuzz test harness
Added roundtrip assertion improves test coverage but does not patch a bug
Evidence from the diff
The diff modifies tests/fuzz/fuzz-channel_id.c. Previously the fuzz harness decoded channel IDs from generated chunks and re-encoded them without comparing results. Now it memcmp()s the re-encoded wire_buf against the original marshal_chunks[i] and asserts equality. It also fixes a minor inefficiency where wire_buf was allocated to the chunk size instead of starting empty (towire_channel_id resizes it). No production wire parsing or serialization logic is changed.
Changed components
tests/fuzz/fuzz-channel_id.cInspect captured patch +4 / −1
diff --git a/tests/fuzz/fuzz-channel_id.c b/tests/fuzz/fuzz-channel_id.c
index c115ba87..6f7eb68d 100644
--- a/tests/fuzz/fuzz-channel_id.c
+++ b/tests/fuzz/fuzz-channel_id.c
@@ -58,9 +58,12 @@ void run(const uint8_t *data, size_t size)
for (size_t i = 0; i < tal_count(marshal_chunks); i++) {
wire_ptr = marshal_chunks[i];
wire_max = tal_count(marshal_chunks[i]);
+
fromwire_channel_id(&wire_ptr, &wire_max, &chan_id);
- wire_buf = tal_arr(NULL, uint8_t, tal_count(marshal_chunks[i]));
+ wire_buf = tal_arr(NULL, uint8_t, 0);
towire_channel_id(&wire_buf, &chan_id);
+ assert(!memcmp(marshal_chunks[i], wire_buf, tal_count(marshal_chunks[i])));
+
tal_free(wire_buf);
}
tal_free(marshal_chunks);
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.