Skip to content

Commit abe0fce

Browse files
henrywangclaude
andcommitted
tests: Fix sha256 digest hex formatting for sha2 0.11 compat
The sha2 0.11 crate no longer implements LowerHex on the digest output type. Format the hash by iterating over bytes instead, which works with both 0.10 and 0.11. Assisted-by: Claude Code (Opus 4.6) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Xiaofeng Wang <henrywangxf@me.com>
1 parent c888b61 commit abe0fce

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,12 @@ mod tests {
679679
// testdata sha256sum are computed with a trailing \n
680680
sha256.update("\n");
681681
let filename = filename.trim_end_matches(".json");
682-
let hash = format!("{:x}", sha256.finalize());
682+
let digest = sha256.finalize();
683+
let hash = digest.iter().fold(String::new(), |mut s, b| {
684+
use std::fmt::Write;
685+
write!(s, "{b:02x}").unwrap();
686+
s
687+
});
683688
assert_eq!(filename, hash);
684689
let json2: serde_json::Value = serde_json::from_slice(&enc)?;
685690

0 commit comments

Comments
 (0)