MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / vault_entry_roundtrip

Function vault_entry_roundtrip

atomic-core/src/pristine/vault.rs:810–832  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

808
809 #[test]
810 fn vault_entry_roundtrip() {
811 let entry = VaultEntry::new(
812 VaultEntryType::Session,
813 b"# Session transcript\nHello world".to_vec(),
814 r#"{"developer":"alice"}"#.to_string(),
815 "2025-01-15T12:00:00Z".to_string(),
816 );
817
818 // Verify content hash is populated
819 assert_ne!(entry.content_hash, [0u8; 32]);
820
821 // Postcard round-trip
822 let bytes = postcard::to_allocvec(&entry).expect("serialize");
823 let decoded: VaultEntry = postcard::from_bytes(&bytes).expect("deserialize");
824
825 assert_eq!(decoded.entry_type, VaultEntryType::Session);
826 assert_eq!(decoded.content_bytes, entry.content_bytes);
827 assert_eq!(decoded.content_hash, entry.content_hash);
828 assert_eq!(decoded.frontmatter_json, entry.frontmatter_json);
829 assert_eq!(decoded.created_at, "2025-01-15T12:00:00Z");
830 assert_eq!(decoded.updated_at, "2025-01-15T12:00:00Z");
831 assert_eq!(decoded.introduced_by, 0);
832 }
833
834 #[test]
835 fn vault_entry_content_size() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected