Make ExpandedDifficulty Debug byte order match Hash
Bugfix on PR #1171.
This commit is contained in:
parent
76a9f5b8c4
commit
8f838166a8
|
@ -98,7 +98,7 @@ impl fmt::Debug for ExpandedDifficulty {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let mut buf = [0; 32];
|
let mut buf = [0; 32];
|
||||||
// Use the same byte order as block::Hash
|
// 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")
|
f.debug_tuple("ExpandedDifficulty")
|
||||||
.field(&hex::encode(&buf))
|
.field(&hex::encode(&buf))
|
||||||
.finish()
|
.finish()
|
||||||
|
|
|
@ -36,7 +36,7 @@ fn debug_format() {
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{:?}", ExpandedDifficulty(U256::one())),
|
format!("{:?}", ExpandedDifficulty(U256::one())),
|
||||||
"ExpandedDifficulty(\"0100000000000000000000000000000000000000000000000000000000000000\")"
|
"ExpandedDifficulty(\"0000000000000000000000000000000000000000000000000000000000000001\")"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{:?}", ExpandedDifficulty(U256::MAX)),
|
format!("{:?}", ExpandedDifficulty(U256::MAX)),
|
||||||
|
@ -44,6 +44,7 @@ fn debug_format() {
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(format!("{:?}", Work(0)), "Work(0x0, 0, -inf)");
|
assert_eq!(format!("{:?}", Work(0)), "Work(0x0, 0, -inf)");
|
||||||
|
assert_eq!(format!("{:?}", Work(1)), "Work(0x1, 1, 0.00000)");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{:?}", Work(u8::MAX as u128)),
|
format!("{:?}", Work(u8::MAX as u128)),
|
||||||
"Work(0xff, 255, 7.99435)"
|
"Work(0xff, 255, 7.99435)"
|
||||||
|
|
Loading…
Reference in New Issue