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