use crate::prelude::*;
pub use ihi::handle_proof;
pub use ihi::handle_to_proof;
pub use ihi::proof_to_filename;
pub use ihi::handle_to_filename;
pub fn handle_to_public_id(handle: &str) -> blake3::Hash {
ihi::handle_to_proof(handle)
}
pub fn public_id_to_filename(id: &blake3::Hash) -> String {
ihi::proof_to_filename(id)
}
pub fn resolve_handle(handle: &str) -> (blake3::Hash, String) {
let id = ihi::handle_to_proof(handle);
let filename = ihi::proof_to_filename(&id);
(id, filename)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn deterministic_proof() {
let hash = blake3::hash(b"test");
let id1 = handle_proof(&hash);
let id2 = handle_proof(&hash);
assert_eq!(id1, id2, "same input must produce same output");
}
#[test]
fn handle_roundtrip() {
let id = ihi::handle_to_proof("text test");
let filename = ihi::proof_to_filename(&id);
assert!(filename.ends_with(".vsf"));
}
#[test]
fn matches_ihi_canonical() {
let (shim_id, shim_filename) = resolve_handle("octopus");
let canonical_id = ihi::handle_to_proof("octopus");
let canonical_filename = ihi::proof_to_filename(&canonical_id);
assert_eq!(shim_id, canonical_id);
assert_eq!(shim_filename, canonical_filename);
}
}