Skip to content

Commit

Permalink
fix: Repartition input schedules in canister migration in state machi…
Browse files Browse the repository at this point in the history
…ne tests (#3381)
  • Loading branch information
stiegerc authored Jan 9, 2025
1 parent 5c6dc53 commit c2b0c10
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions rs/state_machine_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2569,8 +2569,7 @@ impl StateMachine {
/// After you import the canister, you can execute methods on it and upgrade it.
/// The original directory is not modified.
///
/// The function is currently not used in code, but it is useful for local
/// testing and debugging. Do not remove it.
/// This function is useful for local testing and debugging. Do not remove it.
///
/// # Panics
///
Expand All @@ -2580,6 +2579,8 @@ impl StateMachine {
canister_directory: P,
canister_id: CanisterId,
) {
use ic_replicated_state::testing::SystemStateTesting;

let canister_directory = canister_directory.as_ref();
assert!(
canister_directory.is_dir(),
Expand Down Expand Up @@ -2632,7 +2633,7 @@ impl StateMachine {
}
}

let canister_state = ic_state_manager::checkpoint::load_canister_state(
let mut canister_state = ic_state_manager::checkpoint::load_canister_state(
&tip_canister_layout,
&canister_id,
ic_types::Height::new(0),
Expand All @@ -2649,7 +2650,14 @@ impl StateMachine {
.0;

let (h, mut state) = self.state_manager.take_tip();

// Repartition input schedules; Required step for migrating canisters.
canister_state
.system_state
.split_input_schedules(&canister_id, &state.canister_states);

state.put_canister_state(canister_state);

self.state_manager.commit_and_certify(
state,
h.increment(),
Expand Down

0 comments on commit c2b0c10

Please sign in to comment.