Add regression test for Midstate debug output

In preparation for patching the `Debug` implementation of `Midstate` and
a regression test.
This commit is contained in:
Tobin C. Harding 2024-07-12 14:00:46 +10:00
parent ca823945fc
commit 1d0e70b1da
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 13 additions and 8 deletions

View File

@ -1008,15 +1008,20 @@ mod tests {
}
}
// The midstate of an empty hash engine tagged with "TapLeaf".
const TAP_LEAF_MIDSTATE: Midstate = Midstate([
156, 224, 228, 230, 124, 17, 108, 57, 56, 179, 202, 242, 195, 15, 80, 137, 211, 243, 147,
108, 71, 99, 110, 96, 125, 179, 62, 234, 221, 198, 240, 201,
]);
#[test]
fn const_midstate() {
assert_eq!(
Midstate::hash_tag(b"TapLeaf"),
Midstate([
156, 224, 228, 230, 124, 17, 108, 57, 56, 179, 202, 242, 195, 15, 80, 137, 211,
243, 147, 108, 71, 99, 110, 96, 125, 179, 62, 234, 221, 198, 240, 201,
])
)
fn const_midstate() { assert_eq!(Midstate::hash_tag(b"TapLeaf"), TAP_LEAF_MIDSTATE,) }
#[test]
fn regression_midstate_debug_format() {
let want = "0xc9f0c6ddea3eb37d606e63476c93f3d389500fc3f2cab338396c117ce6e4e09c";
let got = format!("{:?}", TAP_LEAF_MIDSTATE);
assert_eq!(got, want);
}
#[test]