Skip to content

Commit

Permalink
Compare FromUserHex result against other hex validators and parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
l0rinc committed Sep 11, 2024
1 parent 1994786 commit 1eac96a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/test/fuzz/hex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ FUZZ_TARGET(hex)
assert(uint256::FromUserHex(random_hex_string));
}
if (const auto result{uint256::FromUserHex(random_hex_string)}) {
assert(uint256::FromHex(result->ToString()));
const auto result_string{result->ToString()}; // ToString() returns a fixed-length string without "0x" prefix
assert(result_string.length() == 64);
assert(IsHex(result_string));
assert(TryParseHex(result_string));
assert(Txid::FromHex(result_string));
assert(Wtxid::FromHex(result_string));
assert(uint256::FromHex(result_string));
}
(void)uint256S(random_hex_string);
try {
Expand Down

0 comments on commit 1eac96a

Please sign in to comment.