mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
fuzz: target for update_blockheight
Fuzz the decoding and encoding of update_blockheight.
This commit is contained in:
parent
eec261101f
commit
6a975f3c1d
37
tests/fuzz/fuzz-wire-update_blockheight.c
Normal file
37
tests/fuzz/fuzz-wire-update_blockheight.c
Normal file
@ -0,0 +1,37 @@
|
||||
#include "config.h"
|
||||
#include <common/channel_id.h>
|
||||
#include <tests/fuzz/libfuzz.h>
|
||||
#include <tests/fuzz/wire.h>
|
||||
#include <wire/peer_wire.h>
|
||||
|
||||
struct update_blockheight {
|
||||
struct channel_id channel_id;
|
||||
u32 blockheight;
|
||||
};
|
||||
|
||||
static void *encode(const tal_t *ctx, const struct update_blockheight *s)
|
||||
{
|
||||
return towire_update_blockheight(ctx, &s->channel_id, s->blockheight);
|
||||
}
|
||||
|
||||
static struct update_blockheight *decode(const tal_t *ctx, const void *p)
|
||||
{
|
||||
struct update_blockheight *s = tal(ctx, struct update_blockheight);
|
||||
|
||||
if (fromwire_update_blockheight(p, &s->channel_id, &s->blockheight))
|
||||
return s;
|
||||
return tal_free(s);
|
||||
}
|
||||
|
||||
static bool equal(const struct update_blockheight *x,
|
||||
const struct update_blockheight *y)
|
||||
{
|
||||
return channel_id_eq(&x->channel_id, &y->channel_id) &&
|
||||
x->blockheight == y->blockheight;
|
||||
}
|
||||
|
||||
void run(const u8 *data, size_t size)
|
||||
{
|
||||
test_decode_encode(data, size, WIRE_UPDATE_BLOCKHEIGHT,
|
||||
struct update_blockheight);
|
||||
}
|
Loading…
Reference in New Issue
Block a user