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

Function replay_from_limit_basic

nodedb-wal/src/segmented.rs:728–750  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

726
727 #[test]
728 fn replay_from_limit_basic() {
729 let dir = tempfile::tempdir().unwrap();
730 let config = test_config(dir.path());
731 let mut wal = SegmentedWal::open(config).unwrap();
732
733 // Append 10 records.
734 for i in 0..10u8 {
735 wal.append(RecordType::Put as u32, 1, 0, 0, &[i]).unwrap();
736 }
737 wal.sync().unwrap();
738
739 // Read all with limit > count.
740 let (records, has_more) = wal.replay_from_limit(1, 100).unwrap();
741 assert_eq!(records.len(), 10);
742 assert!(!has_more);
743
744 // Read with limit = 3.
745 let (records, has_more) = wal.replay_from_limit(1, 3).unwrap();
746 assert_eq!(records.len(), 3);
747 assert!(has_more);
748 assert_eq!(records[0].header.lsn, 1);
749 assert_eq!(records[2].header.lsn, 3);
750 }
751
752 #[test]
753 fn replay_from_limit_with_lsn_filter() {

Callers

nothing calls this directly

Calls 6

test_configFunction · 0.70
openFunction · 0.50
pathMethod · 0.45
appendMethod · 0.45
syncMethod · 0.45
replay_from_limitMethod · 0.45

Tested by

no test coverage detected