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

Function write_and_read_file

nodedb/src/storage/segment.rs:352–366  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

350
351 #[test]
352 fn write_and_read_file() {
353 let dir = tempfile::tempdir().unwrap();
354 let path = dir.path().join("test.seg");
355
356 // Write some data + footer (unencrypted path).
357 std::fs::write(&path, b"segment data here").unwrap();
358 let footer = SegmentFooter::new("test", 42, Lsn::new(1), Lsn::new(50));
359 footer.write_to(&path).unwrap();
360
361 // Read back.
362 let read_footer = SegmentFooter::read_from(&path).unwrap();
363 assert_eq!(read_footer.checksum, 42);
364 assert_eq!(read_footer.min_lsn, Lsn::new(1));
365 assert_eq!(read_footer.max_lsn, Lsn::new(50));
366 }
367
368 #[test]
369 fn write_and_read_file_encrypted_restart_roundtrip() {

Callers

nothing calls this directly

Calls 4

joinMethod · 0.80
write_toMethod · 0.80
writeFunction · 0.50
pathMethod · 0.45

Tested by

no test coverage detected