diff options
| author | practicalswift <[email protected]> | 2019-10-23 15:08:48 +0000 |
|---|---|---|
| committer | practicalswift <[email protected]> | 2019-12-16 22:50:49 +0000 |
| commit | c18405732e38eadb2c47533c3f982f4605fbfd9a (patch) | |
| tree | 832a046dcc171d260be5a07f87df39d766a5e9f2 /src/test/fuzz/hex.cpp | |
| parent | tests: Add fuzzing harness for various Base{32,58,64} related functions (diff) | |
| download | discoin-c18405732e38eadb2c47533c3f982f4605fbfd9a.tar.xz discoin-c18405732e38eadb2c47533c3f982f4605fbfd9a.zip | |
tests: Add fuzzing harness for various hex related functions
Diffstat (limited to 'src/test/fuzz/hex.cpp')
| -rw-r--r-- | src/test/fuzz/hex.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/fuzz/hex.cpp b/src/test/fuzz/hex.cpp new file mode 100644 index 000000000..54693180b --- /dev/null +++ b/src/test/fuzz/hex.cpp @@ -0,0 +1,22 @@ +// Copyright (c) 2019 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 <test/fuzz/fuzz.h> + +#include <util/strencodings.h> + +#include <cassert> +#include <cstdint> +#include <string> +#include <vector> + +void test_one_input(const std::vector<uint8_t>& buffer) +{ + const std::string random_hex_string(buffer.begin(), buffer.end()); + const std::vector<unsigned char> data = ParseHex(random_hex_string); + const std::string hex_data = HexStr(data); + if (IsHex(random_hex_string)) { + assert(ToLower(random_hex_string) == hex_data); + } +} |