Skip to content

test: [DSM-126] Add synchronous commit_and_certify for tests#10131

Open
michael-weigelt wants to merge 2 commits intomasterfrom
mwe/sync_cc2
Open

test: [DSM-126] Add synchronous commit_and_certify for tests#10131
michael-weigelt wants to merge 2 commits intomasterfrom
mwe/sync_cc2

Conversation

@michael-weigelt
Copy link
Copy Markdown
Contributor

@michael-weigelt michael-weigelt commented May 8, 2026

Co-authored by Claude

@github-actions github-actions Bot added the test label May 8, 2026
@michael-weigelt michael-weigelt marked this pull request as ready for review May 8, 2026 09:01
@michael-weigelt michael-weigelt requested a review from a team as a code owner May 8, 2026 09:01
);

/// Testing only: Like `commit_and_certify_at_height`, but waits for hashing/certification metadata.
fn commit_and_certify_at_height_sync(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can these also be used in the state_machine_tests crate and/or pocket_ic?

);
}

fn fetch_state_sync(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That is an unfortunate name, because it's simultaneously not related to state sync and kinda is.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces synchronous, test-only wrappers around StateManagerImpl operations that previously required explicit flush_hash_channel() calls, and updates state manager integration tests to use these wrappers for determinism.

Changes:

  • Add commit_and_certify_sync, commit_and_certify_at_height_sync, and fetch_state_sync to ic_state_manager::testing::StateManagerTesting.
  • Implement these wrappers for StateManagerImpl by delegating to the existing async methods and then flushing the hash channel.
  • Refactor rs/state_manager/tests/state_manager.rs to replace commit_and_certify/commit_and_certify_at_height + flush_hash_channel call pairs with the new synchronous helpers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.

File Description
rs/state_manager/tests/state_manager.rs Replaces explicit hash-channel flushing patterns with new synchronous test helpers.
rs/state_manager/src/lib.rs Adds and implements synchronous test-only helpers that flush the hash channel after committing/fetching.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +4456 to +4460
batch_summary: Option<BatchSummary>,
) {
self.commit_and_certify(state, scope, batch_summary);
self.flush_hash_channel();
}
batch_summary: Option<BatchSummary>,
) {
self.commit_and_certify_at_height(state, height, scope, batch_summary);
self.flush_hash_channel();
Comment on lines +4370 to +4374
/// Testing only: Commits, then waits for hashing/certification metadata to be populated.
fn commit_and_certify_sync(
&self,
state: ReplicatedState,
scope: CertificationScope,
Comment on lines 6355 to +6359
for _i in 2..(divergence + 1) {
let (_height, state) = state_manager.take_tip();
state_manager.commit_and_certify(state, CertificationScope::Metadata, None);
if _i == divergence {
state_manager.commit_and_certify_sync(state, CertificationScope::Metadata, None);
} else {
Comment on lines 1503 to +1507
} else {
CertificationScope::Metadata
};

state_manager.commit_and_certify(state, scope.clone(), None);
state_manager.commit_and_certify_sync(state, scope.clone(), None);
Comment on lines 1566 to +1570
} else {
CertificationScope::Metadata
};

state_manager.commit_and_certify(state, scope.clone(), None);
state_manager.commit_and_certify_sync(state, scope.clone(), None);
};

state_manager.commit_and_certify(state, scope.clone(), None);
state_manager.commit_and_certify_sync(state, scope.clone(), None);
};

state_manager.commit_and_certify(state, scope.clone(), None);
state_manager.commit_and_certify_sync(state, scope.clone(), None);
Comment on lines 1916 to +1921
CertificationScope::Full
} else {
CertificationScope::Metadata
};

state_manager.commit_and_certify(state, scope.clone(), None);
state_manager.commit_and_certify_sync(state, scope.clone(), None);
Comment on lines +1995 to 1996
state_manager.commit_and_certify_sync(state, scope.clone(), None);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants