| 1292 | |
| 1293 | #[test] |
| 1294 | fn test_blake3_hashes() { |
| 1295 | // Test with real blake3 hashes (not synthetic fill patterns) |
| 1296 | let h0 = *blake3::hash(b"change 0").as_bytes(); |
| 1297 | let h1 = *blake3::hash(b"change 1").as_bytes(); |
| 1298 | let h2 = *blake3::hash(b"change 2").as_bytes(); |
| 1299 | |
| 1300 | let mut table = HashDedupTable::new(h0); |
| 1301 | table.insert(h1).unwrap(); |
| 1302 | table.insert(h2).unwrap(); |
| 1303 | |
| 1304 | assert_eq!(table.lookup(&h0), Some(0)); |
| 1305 | assert_eq!(table.lookup(&h1), Some(1)); |
| 1306 | assert_eq!(table.lookup(&h2), Some(2)); |
| 1307 | |
| 1308 | // Roundtrip through serialization |
| 1309 | let mut buf = Vec::new(); |
| 1310 | table.write_to(&mut buf).unwrap(); |
| 1311 | |
| 1312 | let mut cursor = std::io::Cursor::new(&buf); |
| 1313 | let loaded = HashDedupTable::read_from(&mut cursor, 3).unwrap(); |
| 1314 | |
| 1315 | assert_eq!(loaded.resolve(0).unwrap(), &h0); |
| 1316 | assert_eq!(loaded.resolve(1).unwrap(), &h1); |
| 1317 | assert_eq!(loaded.resolve(2).unwrap(), &h2); |
| 1318 | } |
| 1319 | |
| 1320 | // ── Size savings calculation ─────────────────────────────────── |
| 1321 | |