refactor: add uint256::FromUserHex helper

FromUserHex will be used in future commits to construct
uint256 instances from user hex input without being
unnecessarily restrictive on formatting by allowing
0x-prefixed input that is shorter than 64 characters.
This commit is contained in:
stickies-v
2024-08-20 13:41:08 +01:00
parent 85b7cbfcbe
commit 70e2c87737
3 changed files with 55 additions and 0 deletions

View File

@@ -32,6 +32,10 @@ FUZZ_TARGET(hex)
assert(random_hex_string.length() == 64);
assert(Txid::FromHex(random_hex_string));
assert(Wtxid::FromHex(random_hex_string));
assert(uint256::FromUserHex(random_hex_string));
}
if (const auto result{uint256::FromUserHex(random_hex_string)}) {
assert(uint256::FromHex(result->ToString()));
}
(void)uint256S(random_hex_string);
try {