forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fuzz: target for reply_short_channel_ids_end
Fuzz the decoding and encoding of reply_short_channel_ids_end.
- Loading branch information
1 parent
4997d0d
commit 1520fac
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "config.h" | ||
#include <tests/fuzz/libfuzz.h> | ||
#include <tests/fuzz/wire.h> | ||
#include <wire/peer_wire.h> | ||
|
||
struct reply_short_channel_ids_end { | ||
struct bitcoin_blkid chain_hash; | ||
u8 full_information; | ||
}; | ||
|
||
static void *encode(const tal_t *ctx, | ||
const struct reply_short_channel_ids_end *s) | ||
{ | ||
return towire_reply_short_channel_ids_end(ctx, &s->chain_hash, | ||
s->full_information); | ||
} | ||
|
||
static struct reply_short_channel_ids_end *decode(const tal_t *ctx, | ||
const void *p) | ||
{ | ||
struct reply_short_channel_ids_end *s = | ||
tal(ctx, struct reply_short_channel_ids_end); | ||
|
||
if (fromwire_reply_short_channel_ids_end(p, &s->chain_hash, | ||
&s->full_information)) | ||
return s; | ||
return tal_free(s); | ||
} | ||
|
||
static bool equal(const struct reply_short_channel_ids_end *x, | ||
const struct reply_short_channel_ids_end *y) | ||
{ | ||
if (memcmp(&x->chain_hash, &y->chain_hash, sizeof(x->chain_hash)) != 0) | ||
return false; | ||
return x->full_information == y->full_information; | ||
} | ||
|
||
void run(const u8 *data, size_t size) | ||
{ | ||
test_decode_encode(data, size, WIRE_REPLY_SHORT_CHANNEL_IDS_END, | ||
struct reply_short_channel_ids_end); | ||
} |