From d60077a8d947c007a27c668bee2d4edad6b9b01b Mon Sep 17 00:00:00 2001 From: Matt Morehouse Date: Mon, 21 Aug 2023 16:04:13 -0500 Subject: [PATCH] fuzz: target for update_fulfill_htlc Fuzz the decoding and encoding of update_fulfill_htlc. --- tests/fuzz/fuzz-wire-update_fulfill_htlc.c | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/fuzz/fuzz-wire-update_fulfill_htlc.c diff --git a/tests/fuzz/fuzz-wire-update_fulfill_htlc.c b/tests/fuzz/fuzz-wire-update_fulfill_htlc.c new file mode 100644 index 000000000..ed2701187 --- /dev/null +++ b/tests/fuzz/fuzz-wire-update_fulfill_htlc.c @@ -0,0 +1,38 @@ +#include "config.h" +#include +#include +#include + +struct update_fulfill_htlc { + struct channel_id channel_id; + u64 id; + struct preimage payment_preimage; +}; + +static void *encode(const tal_t *ctx, const struct update_fulfill_htlc *s) +{ + return towire_update_fulfill_htlc(ctx, &s->channel_id, s->id, + &s->payment_preimage); +} + +static struct update_fulfill_htlc *decode(const tal_t *ctx, const void *p) +{ + struct update_fulfill_htlc *s = tal(ctx, struct update_fulfill_htlc); + + if (fromwire_update_fulfill_htlc(p, &s->channel_id, &s->id, + &s->payment_preimage)) + return s; + return tal_free(s); +} + +static bool equal(const struct update_fulfill_htlc *x, + const struct update_fulfill_htlc *y) +{ + return memcmp(x, y, sizeof(*x)) == 0; +} + +void run(const u8 *data, size_t size) +{ + test_decode_encode(data, size, WIRE_UPDATE_FULFILL_HTLC, + struct update_fulfill_htlc); +}