fuzz-tests: Add fuzz target for closing_complete
What changed, and why it matters
This commit adds a new automated fuzz test for a Lightning network channel-closing message called 'closing_complete'. It does not change any production code, network behavior, or security logic. It only adds a test file that checks whether the message can be encoded and decoded correctly.
No security action required. This is a test-only addition and can be reviewed as normal quality assurance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit introduces tests/fuzz/fuzz-wire-closing_complete.c, a LibFuzzer target that performs a round-trip towire/fromwire test for WIRE_CLOSING_COMPLETE. It mirrors existing fuzz targets for other peer wire messages and only exercises serialization/deserialization code. No functional code is modified.
Changed components
tests/fuzz/fuzz-wire-closing_complete.cInspect captured patch +53 / −0
diff --git a/tests/fuzz/fuzz-wire-closing_complete.c b/tests/fuzz/fuzz-wire-closing_complete.c
new file mode 100644
index 00000000..bc276060
--- /dev/null
+++ b/tests/fuzz/fuzz-wire-closing_complete.c
@@ -0,0 +1,53 @@
+#include "config.h"
+#include <assert.h>
+#include <ccan/mem/mem.h>
+#include <tests/fuzz/libfuzz.h>
+#include <tests/fuzz/wire.h>
+#include <wire/peer_wire.h>
+
+struct closing_complete {
+ struct channel_id channel_id;
+ u32 locktime;
+ struct amount_sat fee_satoshis;
+ u8 *closer_scriptpubkey, *closee_scriptpubkey;
+ struct tlv_closing_tlvs *tlvs;
+};
+
+static void *encode(const tal_t *ctx, const struct closing_complete *s)
+{
+ return towire_closing_complete(ctx, &s->channel_id, s->closer_scriptpubkey,
+ s->closee_scriptpubkey, s->fee_satoshis, s->locktime, s->tlvs);
+}
+
+static struct closing_complete *decode(const tal_t *ctx, const void *p)
+{
+ struct closing_complete *s = tal(ctx, struct closing_complete);
+
+ if (fromwire_closing_complete(s, p, &s->channel_id, &s->closer_scriptpubkey,
+ &s->closee_scriptpubkey, &s->fee_satoshis, &s->locktime, &s->tlvs))
+ return s;
+ return tal_free(s);
+}
+
+static bool equal(const struct closing_complete *x,
+ const struct closing_complete *y)
+{
+ assert(memcmp(&x->channel_id, &y->channel_id, sizeof(x->channel_id)) == 0);
+ assert(x->locktime == y->locktime);
+ assert(memcmp(&x->fee_satoshis, &y->fee_satoshis, sizeof(x->fee_satoshis)) == 0);
+
+ assert(tal_arr_eq(x->closer_scriptpubkey, y->closer_scriptpubkey));
+ assert(tal_arr_eq(x->closee_scriptpubkey, y->closee_scriptpubkey));
+
+ assert(x->tlvs && y->tlvs);
+ assert(tal_arr_eq(x->tlvs->closer_output_only, y->tlvs->closer_output_only));
+ assert(tal_arr_eq(x->tlvs->closee_output_only, y->tlvs->closee_output_only));
+
+ return tal_arr_eq(x->tlvs->closer_and_closee_outputs, y->tlvs->closer_and_closee_outputs);
+}
+
+void run(const u8 *data, size_t size)
+{
+ test_decode_encode(data, size, WIRE_CLOSING_COMPLETE,
+ struct closing_complete);
+}
Why this scored 15/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.