mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-04 11:08:03 +01:00
fuzz: target for pong
Fuzz the decoding and encoding of pong.
This commit is contained in:
parent
06f37a3c86
commit
c987b0e43c
1 changed files with 34 additions and 0 deletions
34
tests/fuzz/fuzz-wire-pong.c
Normal file
34
tests/fuzz/fuzz-wire-pong.c
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#include "config.h"
|
||||||
|
#include <ccan/mem/mem.h>
|
||||||
|
#include <tests/fuzz/libfuzz.h>
|
||||||
|
#include <tests/fuzz/wire.h>
|
||||||
|
#include <wire/peer_wire.h>
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue