// Copyright (c) 2009-present The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include #include #include #include #include #include #include FUZZ_TARGET(parse_hd_keypath) { const std::string keypath_str(buffer.begin(), buffer.end()); std::vector keypath; (void)ParseHDKeypath(keypath_str, keypath); FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); const std::vector random_keypath = ConsumeRandomLengthIntegralVector(fuzzed_data_provider); // Roundtrip WriteHDKeypath() and ParseHDKeypath() for (const bool apostrophe : {false, true}) { std::vector roundtrip; const std::string written{WriteHDKeypath(random_keypath, apostrophe)}; assert(ParseHDKeypath(written, roundtrip)); assert(roundtrip == random_keypath); } }