| 2192 | |
| 2193 | #[test] |
| 2194 | fn test_hash_stability() { |
| 2195 | // Same change content should always produce same hash |
| 2196 | // Use a fixed timestamp to ensure deterministic hashing |
| 2197 | let fixed_ts = chrono::DateTime::parse_from_rfc3339("2024-01-15T10:30:00Z") |
| 2198 | .unwrap() |
| 2199 | .with_timezone(&chrono::Utc); |
| 2200 | |
| 2201 | let make_change = || { |
| 2202 | let header = ChangeHeader::builder() |
| 2203 | .message("Stable hash test") |
| 2204 | .timestamp(fixed_ts) |
| 2205 | .build(); |
| 2206 | Change::new(header, vec![], b"content".to_vec(), vec![]) |
| 2207 | }; |
| 2208 | |
| 2209 | let hash1 = make_change().hash().unwrap(); |
| 2210 | let hash2 = make_change().hash().unwrap(); |
| 2211 | |
| 2212 | assert_eq!(hash1, hash2); |
| 2213 | } |
| 2214 | |
| 2215 | #[test] |
| 2216 | fn test_v3_magic_bytes() { |