From 6b210e4bba1b526e538ad8c62c08e51eb7b68cbf Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 6 Nov 2024 21:03:37 +0100 Subject: [PATCH] fsverity: add digest testcase Add a test case from the original composefs Rust code. --- src/fsverity/digest.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/fsverity/digest.rs b/src/fsverity/digest.rs index f1c4753..c12531d 100644 --- a/src/fsverity/digest.rs +++ b/src/fsverity/digest.rs @@ -147,3 +147,23 @@ impl FsVerityHasher { context.finalize().into() } } + +#[cfg(test)] +mod tests { + use anyhow::Result; + + use super::*; + + #[test] + fn test_digest() -> Result<()> { + let digest = FsVerityHasher::hash(b"hello world"); + assert_eq!( + digest, + [ + 30, 46, 170, 66, 2, 215, 80, 164, 17, 116, 238, 69, 73, 112, 185, 44, 27, 194, 249, + 37, 177, 227, 80, 118, 216, 199, 213, 245, 99, 98, 186, 100 + ] + ); + Ok(()) + } +}