2023-08-21 15:51:18 -05:00
|
|
|
#include "config.h"
|
|
|
|
#include <ccan/mem/mem.h>
|
|
|
|
#include <tests/fuzz/libfuzz.h>
|
|
|
|
#include <tests/fuzz/wire.h>
|
|
|
|
#include <wire/peer_wire.h>
|
|
|
|
|
|
|
|
struct ping {
|
|
|
|
u16 num_pong_bytes;
|
|
|
|
u8 *ignored;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void *encode(const tal_t *ctx, const struct ping *s)
|
|
|
|
{
|
|
|
|
return towire_ping(ctx, s->num_pong_bytes, s->ignored);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ping *decode(const tal_t *ctx, const void *p)
|
|
|
|
{
|
|
|
|
struct ping *s = tal(ctx, struct ping);
|
|
|
|
|
|
|
|
if (fromwire_ping(s, p, &s->num_pong_bytes, &s->ignored))
|
|
|
|
return s;
|
|
|
|
return tal_free(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool equal(const struct ping *x, const struct ping *y)
|
|
|
|
{
|
|
|
|
if (x->num_pong_bytes != y->num_pong_bytes)
|
|
|
|
return false;
|
2024-02-14 20:08:33 +10:30
|
|
|
return tal_arr_eq(x->ignored, y->ignored);
|
2023-08-21 15:51:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void run(const u8 *data, size_t size)
|
|
|
|
{
|
|
|
|
test_decode_encode(data, size, WIRE_PING, struct ping);
|
|
|
|
}
|