()
| 234 | |
| 235 | #[test] |
| 236 | fn snapshot_compaction() { |
| 237 | let mut log = RaftLog::new(MemStorage::new()); |
| 238 | for i in 1..=10 { |
| 239 | log.append(make_entry(1, i)).unwrap(); |
| 240 | } |
| 241 | |
| 242 | log.apply_snapshot(5, 1); |
| 243 | assert_eq!(log.snapshot_index(), 5); |
| 244 | assert_eq!(log.last_index(), 10); |
| 245 | // Compacted entries are gone. |
| 246 | assert!(log.entry_at(3).is_none()); |
| 247 | assert!(log.entry_at(5).is_none()); // snapshot boundary |
| 248 | assert!(log.entry_at(6).is_some()); |
| 249 | |
| 250 | // Range query into compacted region fails. |
| 251 | assert!(log.entries_range(3, 8).is_err()); |
| 252 | } |
| 253 | } |
nothing calls this directly
no test coverage detected