Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example(exex): tests for In Memory State #8682

Merged
merged 8 commits into from
Jun 11, 2024

Conversation

shekhirin
Copy link
Collaborator

@shekhirin shekhirin commented Jun 7, 2024

Adds tests for the "In Memory State" ExEx example, showing how you can assert the internal state of the ExEx. It requires implementing the Future manually, so that you still could access the struct after polling it.

@shekhirin shekhirin force-pushed the alexey/exex-in-memory-state-test branch from 72b2afe to 1837819 Compare June 7, 2024 17:56
@shekhirin shekhirin force-pushed the alexey/exex-in-memory-state-test branch from 1837819 to b9fde18 Compare June 7, 2024 18:01
Copy link
Member

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

nice

Comment on lines +32 to +49
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.get_mut();

while let Some(notification) = ready!(this.ctx.notifications.poll_recv(cx)) {
match &notification {
ExExNotification::ChainCommitted { new } => {
info!(committed_chain = ?new.range(), "Received commit");
}
ExExNotification::ChainReorged { old, new } => {
// revert to block before the reorg
this.state.revert_to(new.first().number - 1);
info!(from_chain = ?old.range(), to_chain = ?new.range(), "Received reorg");
}
ExExNotification::ChainReverted { old } => {
this.state.revert_to(old.first().number - 1);
info!(reverted_chain = ?old.range(), "Received revert");
}
};
Copy link
Member

Choose a reason for hiding this comment

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

in this case we should also explain a nice UX for how you'd call async functions inside the future loop?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, but I'm still unsure what's the best approach here. So I think we should merge this PR first as it's about the testing, and then mention what you said in the book.

@shekhirin shekhirin added A-exex Execution Extensions C-example Examples labels Jun 10, 2024
@shekhirin shekhirin marked this pull request as ready for review June 10, 2024 16:04
@shekhirin shekhirin requested review from onbjerg and mattsse June 10, 2024 16:04
@shekhirin shekhirin added this pull request to the merge queue Jun 11, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 11, 2024
@shekhirin shekhirin force-pushed the alexey/exex-in-memory-state-test branch from 825e128 to 6d2ec02 Compare June 11, 2024 10:33
@shekhirin shekhirin force-pushed the alexey/exex-in-memory-state-test branch from 6d2ec02 to ecc565f Compare June 11, 2024 12:29
@shekhirin shekhirin added this pull request to the merge queue Jun 11, 2024
Merged via the queue into main with commit 830a1f5 Jun 11, 2024
30 checks passed
@shekhirin shekhirin deleted the alexey/exex-in-memory-state-test branch June 11, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exex Execution Extensions C-example Examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants