From 9fababd66874a1db30d4b84d23a17dda70e6f4b2 Mon Sep 17 00:00:00 2001 From: Matt Morehouse Date: Mon, 21 Aug 2023 15:44:11 -0500 Subject: [PATCH] fuzz: target for funding_signed Fuzz the decoding and encoding of funding_signed. --- tests/fuzz/fuzz-wire-funding_signed.c | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/fuzz/fuzz-wire-funding_signed.c diff --git a/tests/fuzz/fuzz-wire-funding_signed.c b/tests/fuzz/fuzz-wire-funding_signed.c new file mode 100644 index 000000000..4d5915238 --- /dev/null +++ b/tests/fuzz/fuzz-wire-funding_signed.c @@ -0,0 +1,35 @@ +#include "config.h" +#include +#include +#include + +struct funding_signed { + struct channel_id channel_id; + secp256k1_ecdsa_signature signature; +}; + +static void *encode(const tal_t *ctx, const struct funding_signed *s) +{ + return towire_funding_signed(ctx, &s->channel_id, &s->signature); +} + +static struct funding_signed *decode(const tal_t *ctx, const void *p) +{ + struct funding_signed *s = tal(ctx, struct funding_signed); + + if (fromwire_funding_signed(p, &s->channel_id, &s->signature)) + return s; + return tal_free(s); +} + +static bool equal(const struct funding_signed *x, + const struct funding_signed *y) +{ + return memcmp(x, y, sizeof(*x)) == 0; +} + +void run(const u8 *data, size_t size) +{ + test_decode_encode(data, size, WIRE_FUNDING_SIGNED, + struct funding_signed); +}