Skip to content

Commit f0869eb

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 f0869eb

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,14 @@ 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
684+
.iter()
685+
.fold(String::new(), |mut s, b| {
686+
use std::fmt::Write;
687+
write!(s, "{b:02x}").unwrap();
688+
s
689+
});
683690
assert_eq!(filename, hash);
684691
let json2: serde_json::Value = serde_json::from_slice(&enc)?;
685692

0 commit comments

Comments
 (0)