Skip to content

test: canister invariant checks#9372

Draft
mraszyk wants to merge 1 commit intomasterfrom
mraszyk/canister-invariant-checks-in-tests
Draft

test: canister invariant checks#9372
mraszyk wants to merge 1 commit intomasterfrom
mraszyk/canister-invariant-checks-in-tests

Conversation

@mraszyk
Copy link
Contributor

@mraszyk mraszyk commented Mar 14, 2026

This PR performs the following changes:

  • hardens canister invariant checks by asserting that the actual canister snapshot memory usage matches the cached memory usage;
  • asserts canister invariant checks in ExecutionTest and SchedulerTest unit test frameworks;
  • fixes ExecutionTest::execute_response to release the response slot;
  • introduces functions SystemState::release_reserved_response_slot_for_testing and CanisterQueues::release_reserved_response_slot_for_testing to release a response slot in tests (see previous point);
  • uses a non-empty canister WASM in SchedulerTest so that canister snapshots have non-zero size and asserts about their memory usage are meaningful;
  • hardens canister snapshot tests by asserting that loading a canister snapshot does not "consume" (i.e., remove) the snapshot.

(The motivation for this PR are potential bugs from previous work that might not be caught reliably by tests.)

@github-actions github-actions bot added the test label Mar 14, 2026
Comment on lines +1593 to +1600
pub fn release_reserved_response_slot_for_testing(&mut self, response: &Response) {
let (input_queue, _output_queue) = self
.canister_queues
.get_mut(&response.respondent)
.expect("No matching queue.");
Arc::make_mut(input_queue).release_reserved_response_slot();
self.queue_stats.on_push_timeout_response();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this look good to you, @alin-at-dfinity ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant