Skip to content

Commit 1532259

Browse files
tests: Add fuzzing coverage for FormatHDKeypath(...) and WriteHDKeypath(...)
1 parent 90b635e commit 1532259

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/test/fuzz/parse_hd_keypath.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,22 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#include <test/fuzz/FuzzedDataProvider.h>
56
#include <test/fuzz/fuzz.h>
7+
#include <test/fuzz/util.h>
68
#include <util/bip32.h>
79

10+
#include <cstdint>
11+
#include <vector>
12+
813
void test_one_input(const std::vector<uint8_t>& buffer)
914
{
1015
const std::string keypath_str(buffer.begin(), buffer.end());
1116
std::vector<uint32_t> keypath;
1217
(void)ParseHDKeypath(keypath_str, keypath);
18+
19+
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
20+
const std::vector<uint32_t> random_keypath = ConsumeRandomLengthIntegralVector<uint32_t>(fuzzed_data_provider);
21+
(void)FormatHDKeypath(random_keypath);
22+
(void)WriteHDKeypath(random_keypath);
1323
}

0 commit comments

Comments
 (0)