-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
72b2afe
to
1837819
Compare
1837819
to
b9fde18
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
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 ¬ification { | ||
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"); | ||
} | ||
}; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
825e128
to
6d2ec02
Compare
6d2ec02
to
ecc565f
Compare
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.