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

Function snapshot_needed_after_compaction

nodedb-raft/src/node/core.rs:335–364  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

333
334 #[test]
335 fn snapshot_needed_after_compaction() {
336 let config = test_config(1, vec![2, 3]);
337 let mut node = RaftNode::new(config, MemStorage::new());
338
339 node.election_deadline = Instant::now() - Duration::from_millis(1);
340 node.tick();
341 let _ready = node.take_ready();
342 let resp = crate::message::RequestVoteResponse {
343 term: 1,
344 vote_granted: true,
345 };
346 node.handle_request_vote_response(2, &resp);
347 assert_eq!(node.role(), NodeRole::Leader);
348 let _ = node.take_ready();
349
350 for i in 0..9 {
351 node.propose(vec![i]).unwrap();
352 }
353 let _ = node.take_ready();
354
355 node.log.apply_snapshot(8, 1);
356
357 node.replicate_to_all();
358 let ready = node.take_ready();
359
360 assert!(
361 !ready.snapshots_needed.is_empty(),
362 "expected snapshots_needed to be non-empty"
363 );
364 }
365
366 #[test]
367 fn starts_as_learner_role() {

Callers

nothing calls this directly

Calls 8

nowFunction · 0.85
take_readyMethod · 0.80
apply_snapshotMethod · 0.80
replicate_to_allMethod · 0.80
test_configFunction · 0.70
tickMethod · 0.45
proposeMethod · 0.45

Tested by

no test coverage detected