Skip to content

Commit 5af4f63

Browse files
author
Chandra Pratap
committed
fuzz-tests: add a test for handle_peer_error_or_warning()
handle_peer_error_or_warning() in common/read_peer_message is responsible for parsing any incoming `error` or `warning` messages as defined in BOLT #1. Add a test for it.
1 parent 396d0a9 commit 5af4f63

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tests/fuzz/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ FUZZ_COMMON_OBJS := \
4848
common/memleak.o \
4949
common/msg_queue.o \
5050
common/node_id.o \
51+
common/peer_billboard.o \
52+
common/peer_failed.o \
53+
common/peer_io.o \
54+
common/peer_status_wiregen.o \
5155
common/permute_tx.o \
5256
common/psbt_keypath.o \
57+
common/read_peer_msg.o \
5358
common/sciddir_or_pubkey.o \
5459
common/setup.o \
5560
common/status.o \
@@ -58,6 +63,7 @@ FUZZ_COMMON_OBJS := \
5863
common/utils.o \
5964
common/version.o \
6065
common/wireaddr.o \
66+
common/wire_error.o \
6167
wire/bolt12_wiregen.o \
6268
wire/channel_type_wiregen.o \
6369
wire/fromwire.o \

tests/fuzz/fuzz-error-warning.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "config.h"
2+
#include <common/per_peer_state.h>
3+
#include <common/read_peer_msg.h>
4+
#include <tests/fuzz/libfuzz.h>
5+
6+
void init(int *argc, char ***argv)
7+
{
8+
}
9+
10+
void run(const u8 *data, size_t size)
11+
{
12+
struct per_peer_state pps = { .peer_fd = -1 };
13+
u8 *buf = tal_dup_arr(NULL, u8, data, size, 0);
14+
handle_peer_error_or_warning(&pps, buf);
15+
16+
tal_free(buf);
17+
}

0 commit comments

Comments
 (0)