Make ExpandedDifficulty Debug byte order match Hash

Bugfix on PR #1171.
This commit is contained in:
teor 2020-11-11 00:45:53 +10:00
parent 76a9f5b8c4
commit 8f838166a8
2 changed files with 3 additions and 2 deletions

View File

@ -98,7 +98,7 @@ impl fmt::Debug for ExpandedDifficulty {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut buf = [0; 32];
// Use the same byte order as block::Hash
self.0.to_little_endian(&mut buf);
self.0.to_big_endian(&mut buf);
f.debug_tuple("ExpandedDifficulty")
.field(&hex::encode(&buf))
.finish()

View File

@ -36,7 +36,7 @@ fn debug_format() {
);
assert_eq!(
format!("{:?}", ExpandedDifficulty(U256::one())),
"ExpandedDifficulty(\"0100000000000000000000000000000000000000000000000000000000000000\")"
"ExpandedDifficulty(\"0000000000000000000000000000000000000000000000000000000000000001\")"
);
assert_eq!(
format!("{:?}", ExpandedDifficulty(U256::MAX)),
@ -44,6 +44,7 @@ fn debug_format() {
);
assert_eq!(format!("{:?}", Work(0)), "Work(0x0, 0, -inf)");
assert_eq!(format!("{:?}", Work(1)), "Work(0x1, 1, 0.00000)");
assert_eq!(
format!("{:?}", Work(u8::MAX as u128)),
"Work(0xff, 255, 7.99435)"