diff --git a/tests/fuzz/fuzz-wire-pong.c b/tests/fuzz/fuzz-wire-pong.c new file mode 100644 index 000000000..ff09b4f4a --- /dev/null +++ b/tests/fuzz/fuzz-wire-pong.c @@ -0,0 +1,34 @@ +#include "config.h" +#include +#include +#include +#include + +struct pong { + u8 *ignored; +}; + +static void *encode(const tal_t *ctx, const struct pong *s) +{ + return towire_pong(ctx, s->ignored); +} + +static struct pong *decode(const tal_t *ctx, const void *p) +{ + struct pong *s = tal(ctx, struct pong); + + if (fromwire_pong(s, p, &s->ignored)) + return s; + return tal_free(s); +} + +static bool equal(const struct pong *x, const struct pong *y) +{ + return memeq(x->ignored, tal_bytelen(x->ignored), y->ignored, + tal_bytelen(y->ignored)); +} + +void run(const u8 *data, size_t size) +{ + test_decode_encode(data, size, WIRE_PONG, struct pong); +}