Skip to content

Commit

Permalink
adjust can_purge_intermediate_snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
ShuoWangNSL committed Oct 1, 2024
1 parent e2a78ab commit 7ce78f8
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions rs/state_manager/tests/state_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1928,16 +1928,13 @@ fn can_purge_intermediate_snapshots() {
state_manager.flush_tip_channel();
assert_eq!(state_manager.list_state_heights(CERT_ANY), heights);

// Checkpoint @5 is kept because it is the latest checkpoint at or below the
// requested height 9.
// Intermediate states from @6 to @8 are purged.
// Intermediate snapshots from @1 to @8 are purged.
state_manager.remove_states_below(height(9));
state_manager.flush_deallocation_channel();
assert_eq!(
state_manager.list_state_heights(CERT_ANY),
vec![
height(0),
height(5),
height(9),
height(10),
height(11),
Expand All @@ -1955,21 +1952,12 @@ fn can_purge_intermediate_snapshots() {
],
);

// Checkpoint @20 is kept because it is the most recent
// checkpoint. @15 is kept because @19 depends on it.
// Intermediate states from @16 to @18 are purged.
// Intermediate states from @10 to @18 are purged.
state_manager.remove_states_below(height(19));
state_manager.flush_deallocation_channel();
assert_eq!(
state_manager.list_state_heights(CERT_ANY),
vec![
height(0),
height(15),
height(19),
height(20),
height(21),
height(22)
],
vec![height(0), height(19), height(20), height(21), height(22)],
);

// Test calling `remove_states_below` at the latest checkpoint height.
Expand All @@ -1988,7 +1976,7 @@ fn can_purge_intermediate_snapshots() {
state_manager.flush_deallocation_channel();
assert_eq!(
state_manager.list_state_heights(CERT_ANY),
vec![height(0), height(20), height(22)],
vec![height(0), height(22)],
);

// Test calling `remove_states_below` at a higher height than the latest state
Expand All @@ -1999,7 +1987,7 @@ fn can_purge_intermediate_snapshots() {
state_manager.flush_deallocation_channel();
assert_eq!(
state_manager.list_state_heights(CERT_ANY),
vec![height(0), height(20), height(22)],
vec![height(0), height(22)],
);
})
}
Expand Down

0 comments on commit 7ce78f8

Please sign in to comment.