#[cfg(test)] mod tests { use crate::domain::entities::{RecoveryPhrase, PublicKey, Did, Seed, PrivateKey}; use zeroize::Zeroize; #[test] fn test_recovery_phrase_creation() { let words = vec![ "word1".to_string(), "word2".to_string(), "word3".to_string(), ]; let phrase = RecoveryPhrase::new(words.clone()); assert_eq!(phrase.words(), &words); assert_eq!(phrase.to_string(), "word1 word2 word3"); } #[test] fn test_did_generation() { let public_key = PublicKey(vec![1, 2, 3, 4, 5]); let did = Did::new(&public_key); assert!(did.as_str().starts_with("did:sharenet:")); assert!(did.as_str().contains(&hex::encode(&public_key.0))); } #[test] fn test_seed_zeroization() { let mut seed = Seed::new(vec![1, 2, 3, 4, 5]); // Access the bytes let bytes = seed.as_bytes(); assert_eq!(bytes, &[1, 2, 3, 4, 5]); // Zeroize should clear the data seed.zeroize(); // After zeroization, bytes should be empty (zeroize clears the vector) assert_eq!(seed.as_bytes(), &[]); } #[test] fn test_private_key_zeroization() { let mut private_key = PrivateKey(vec![1, 2, 3, 4, 5]); // Zeroize should clear the data private_key.zeroize(); // After zeroization, bytes should be empty (zeroize clears the vector) assert_eq!(private_key.0, vec![]); } }