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

Function test_hash_stability

atomic-core/src/change/change.rs:1218–1237  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1216
1217 #[test]
1218 fn test_hash_stability() {
1219 // Same change content should always produce same hash
1220 // Use a fixed timestamp to ensure deterministic hashing
1221 let fixed_ts = chrono::DateTime::parse_from_rfc3339("2024-01-15T10:30:00Z")
1222 .unwrap()
1223 .with_timezone(&chrono::Utc);
1224
1225 let make_change = || {
1226 let header = ChangeHeader::builder()
1227 .message("Stable hash test")
1228 .timestamp(fixed_ts)
1229 .build();
1230 Change::new(header, vec![], b"content".to_vec(), vec![])
1231 };
1232
1233 let hash1 = make_change().hash().unwrap();
1234 let hash2 = make_change().hash().unwrap();
1235
1236 assert_eq!(hash1, hash2);
1237 }
1238
1239 #[test]
1240 fn test_v3_magic_bytes() {

Callers

nothing calls this directly

Calls 6

make_changeFunction · 0.50
unwrapMethod · 0.45
buildMethod · 0.45
timestampMethod · 0.45
messageMethod · 0.45
hashMethod · 0.45

Tested by

no test coverage detected