File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ FUZZ_TARGETS = \
28
28
test/fuzz/eval_script \
29
29
test/fuzz/fee_rate_deserialize \
30
30
test/fuzz/flat_file_pos_deserialize \
31
+ test/fuzz/hex \
31
32
test/fuzz/integer \
32
33
test/fuzz/inv_deserialize \
33
34
test/fuzz/key_origin_info_deserialize \
@@ -363,6 +364,12 @@ test_fuzz_address_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
363
364
test_fuzz_address_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
364
365
test_fuzz_address_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
365
366
367
+ test_fuzz_hex_SOURCES = $(FUZZ_SUITE) test/fuzz/hex.cpp
368
+ test_fuzz_hex_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
369
+ test_fuzz_hex_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
370
+ test_fuzz_hex_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
371
+ test_fuzz_hex_LDADD = $(FUZZ_SUITE_LD_COMMON)
372
+
366
373
test_fuzz_inv_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
367
374
test_fuzz_inv_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DINV_DESERIALIZE=1
368
375
test_fuzz_inv_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2019 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 < test/fuzz/fuzz.h>
6
+
7
+ #include < util/strencodings.h>
8
+
9
+ #include < cassert>
10
+ #include < cstdint>
11
+ #include < string>
12
+ #include < vector>
13
+
14
+ void test_one_input (const std::vector<uint8_t >& buffer)
15
+ {
16
+ const std::string random_hex_string (buffer.begin (), buffer.end ());
17
+ const std::vector<unsigned char > data = ParseHex (random_hex_string);
18
+ const std::string hex_data = HexStr (data);
19
+ if (IsHex (random_hex_string)) {
20
+ assert (ToLower (random_hex_string) == hex_data);
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments