MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / write_read_roundtrip

Function write_read_roundtrip

crates/commitlog/src/segment.rs:785–809  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

783
784 #[test]
785 fn write_read_roundtrip() {
786 let repo = repo::Memory::unlimited();
787
788 let mut writer = repo::create_segment_writer(&repo, <_>::default(), Commit::DEFAULT_EPOCH, 0).unwrap();
789 writer.commit([(0, [0; 32]), (1, [1; 32]), (2, [2; 32])]).unwrap();
790 writer.flush().unwrap();
791
792 let reader = repo::open_segment_reader(&repo, DEFAULT_LOG_FORMAT_VERSION, 0).unwrap();
793 let header = reader.header;
794 let commit = reader
795 .commits()
796 .next()
797 .expect("expected one commit")
798 .expect("unexpected IO");
799
800 assert_eq!(
801 header,
802 Header {
803 log_format_version: DEFAULT_LOG_FORMAT_VERSION,
804 checksum_algorithm: DEFAULT_CHECKSUM_ALGORITHM
805 }
806 );
807 assert_eq!(commit.min_tx_offset, 0);
808 assert_eq!(commit.records, [[0; 32], [1; 32], [2; 32]].concat());
809 }
810
811 #[test]
812 fn metadata() {

Callers

nothing calls this directly

Calls 7

create_segment_writerFunction · 0.85
open_segment_readerFunction · 0.85
commitMethod · 0.65
unwrapMethod · 0.45
flushMethod · 0.45
nextMethod · 0.45
commitsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…