Coverage Report

Created: 2026-10-07 20:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/bitcoin/src/test/fuzz/parse_hd_keypath.cpp
Line
Count
Source
1
// Copyright (c) 2009-present 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/FuzzedDataProvider.h>
6
#include <test/fuzz/fuzz.h>
7
#include <test/fuzz/util.h>
8
#include <util/bip32.h>
9
10
#include <cassert>
11
#include <cstdint>
12
#include <vector>
13
14
FUZZ_TARGET(parse_hd_keypath)
15
0
{
16
0
    const std::string keypath_str(buffer.begin(), buffer.end());
17
0
    std::vector<uint32_t> keypath;
18
0
    (void)ParseHDKeypath(keypath_str, keypath);
19
20
0
    FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
21
0
    const std::vector<uint32_t> random_keypath = ConsumeRandomLengthIntegralVector<uint32_t>(fuzzed_data_provider);
22
23
    // Roundtrip WriteHDKeypath() and ParseHDKeypath()
24
0
    for (const bool apostrophe : {false, true}) {
  Branch (24:32): [True: 0, False: 0]
25
0
        std::vector<uint32_t> roundtrip;
26
0
        const std::string written{WriteHDKeypath(random_keypath, apostrophe)};
27
0
        assert(ParseHDKeypath(written, roundtrip));
  Branch (27:9): [True: 0, False: 0]
28
0
        assert(roundtrip == random_keypath);
  Branch (28:9): [True: 0, False: 0]
29
0
    }
30
0
}