MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / crc_corruption_rejected

Function crc_corruption_rejected

nodedb-vector/src/mmap_segment/reader.rs:654–668  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

652
653 #[test]
654 fn crc_corruption_rejected() {
655 let dir = tempfile::tempdir().unwrap();
656 let path = dir.path().join("corrupt.vseg");
657
658 let v = vec![1.0f32, 2.0, 3.0];
659 write_segment(&path, 3, &[&v], &[42]).unwrap();
660
661 let mut data = std::fs::read(&path).unwrap();
662 data[HEADER_SIZE] ^= 0xff;
663 std::fs::write(&path, &data).unwrap();
664
665 let result = MmapVectorSegment::open(&path);
666 assert!(result.is_err(), "expected CRC error");
667 assert_eq!(result.unwrap_err().kind(), std::io::ErrorKind::InvalidData);
668 }
669
670 #[test]
671 fn bad_magic_rejected() {

Callers

nothing calls this directly

Calls 6

joinMethod · 0.80
write_segmentFunction · 0.70
readFunction · 0.50
writeFunction · 0.50
openFunction · 0.50
pathMethod · 0.45

Tested by

no test coverage detected