Skip to content

Commit

Permalink
fsverity: add digest testcase
Browse files Browse the repository at this point in the history
Add a test case from the original composefs Rust code.
  • Loading branch information
cgwalters authored and allisonkarlitskaya committed Nov 7, 2024
1 parent fdff073 commit 6b210e4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/fsverity/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}

0 comments on commit 6b210e4

Please sign in to comment.