Skip to content

Commit dd80a08

Browse files
committed
pow: Unit test from_hex_internal
Add a unit test that fails if put before the "pow: Fix off-by-one error" patch. Tests that we can correctly parse a 32 character long hex string into a `U256`.
1 parent c16f7ad commit dd80a08

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

bitcoin/src/pow.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,14 @@ mod tests {
15891589
assert_eq!(got, val);
15901590
}
15911591

1592+
#[test]
1593+
fn u256_from_hex_32_characters_long() {
1594+
let hex = "a69b455cd41bb662a69b4555deadbeef";
1595+
let want = U256(0x00, 0xA69B_455C_D41B_B662_A69B_4555_DEAD_BEEF);
1596+
let got = U256::from_unprefixed_hex(hex).expect("failed to parse hex");
1597+
assert_eq!(got, want);
1598+
}
1599+
15921600
#[cfg(feature = "serde")]
15931601
#[test]
15941602
fn u256_serde() {

0 commit comments

Comments
 (0)