Skip to content

Commit

Permalink
fuzz: target for splice_locked
Browse files Browse the repository at this point in the history
Fuzz the decoding and encoding of splice_locked.
  • Loading branch information
morehouse authored and rustyrussell committed Sep 18, 2023
1 parent ae56dcf commit 34ca0f6
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/fuzz/fuzz-wire-splice_locked.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "config.h"
#include <tests/fuzz/libfuzz.h>
#include <tests/fuzz/wire.h>
#include <wire/peer_wire.h>

struct splice_locked {
struct channel_id channel_id;
};

static void *encode(const tal_t *ctx, const struct splice_locked *s)
{
return towire_splice_locked(ctx, &s->channel_id);
}

static struct splice_locked *decode(const tal_t *ctx, const void *p)
{
struct splice_locked *s = tal(ctx, struct splice_locked);

if (fromwire_splice_locked(p, &s->channel_id))
return s;
return tal_free(s);
}

static bool equal(const struct splice_locked *x, const struct splice_locked *y)
{
return memcmp(x, y, sizeof(*x)) == 0;
}

void run(const u8 *data, size_t size)
{
test_decode_encode(data, size, WIRE_SPLICE_LOCKED,
struct splice_locked);
}

0 comments on commit 34ca0f6

Please sign in to comment.