Skip to content

Commit 4ddbcd0

Browse files
fuzz: Add coverage for CDataStream consumer
1 parent 546a076 commit 4ddbcd0

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/Makefile.test.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ test_fuzz_fuzz_SOURCES = \
210210
test/fuzz/crypto_hkdf_hmac_sha256_l32.cpp \
211211
test/fuzz/crypto_poly1305.cpp \
212212
test/fuzz/cuckoocache.cpp \
213+
test/fuzz/data_stream.cpp \
213214
test/fuzz/decode_tx.cpp \
214215
test/fuzz/descriptor_parse.cpp \
215216
test/fuzz/deserialize.cpp \

src/test/fuzz/data_stream.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (c) 2020 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include <addrman.h>
6+
#include <net.h>
7+
#include <test/fuzz/FuzzedDataProvider.h>
8+
#include <test/fuzz/fuzz.h>
9+
#include <test/fuzz/util.h>
10+
11+
#include <cstdint>
12+
#include <vector>
13+
14+
void initialize_data_stream_addr_man()
15+
{
16+
InitializeFuzzingContext();
17+
}
18+
19+
FUZZ_TARGET_INIT(data_stream_addr_man, initialize_data_stream_addr_man)
20+
{
21+
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
22+
CDataStream data_stream = ConsumeDataStream(fuzzed_data_provider);
23+
CAddrMan addr_man;
24+
CAddrDB::Read(addr_man, data_stream);
25+
}

0 commit comments

Comments
 (0)