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

fix: make gossip portal-interop test auto generate comments for errors #118

Merged
merged 3 commits into from
Jan 11, 2024

Conversation

KolbyML
Copy link
Member

@KolbyML KolbyML commented Dec 1, 2023

Since we can dynamically add tests over time we also need a way of generating the error comments dynamically

@KolbyML KolbyML self-assigned this Dec 1, 2023
@KolbyML KolbyML force-pushed the make-errors-auto-gen branch 2 times, most recently from 51ae840 to 3e76fa4 Compare December 1, 2023 18:01
@KolbyML KolbyML marked this pull request as ready for review December 1, 2023 18:01
@KolbyML KolbyML changed the title fix: make gossip portal-interop test auto generate errors fix: make gossip portal-interop test auto generate comments for errors Dec 1, 2023
// wait content_vec.len() seconds for data to propagate, giving more time if more items are propagating
tokio::time::sleep(Duration::from_secs(test_data.len() as u64)).await;

let (first_header_key, first_header_value) = test_data.get(0).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Could you elaborate on what is happening here, what the first header and last header are, why we set the first as last, and how this relates to comments?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious about this too.

Copy link
Member Author

@KolbyML KolbyML Dec 5, 2023

Choose a reason for hiding this comment

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

Last header seen. We are setting it here because the rust borrow checker won't allow us to set unassigned variables.

So at the start the last seen header would be the first header, because it is the only one we know about at the start therefore being the last header seen

Copy link
Contributor

Choose a reason for hiding this comment

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

It's worth adding a docstring to the code for reference

"7000000 receipt", "15600000 (post-merge) header", "15600000 (post-merge) block body", "15600000 (post-merge) receipt",
"17510000 (post-shanghai) header", "17510000 (post-shanghai) block body", "17510000 (post-shanghai) receipt"];

// wait content_vec.len() seconds for data to propagate, giving more time if more items are propagating
Copy link
Contributor

Choose a reason for hiding this comment

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

// wait test_data.len() seconds ...

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure what you are trying to imply?

Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm not mistaken, the comment is incorrect. We are using test_data.len() in the line below to figure out how long the wait should be, so the comment should be updated with test_data.len() instead of content_vec.len()

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh I see what you mean, must have forgot to to copy the commit when I took copy pasted that timeout from trin-bridge tests I will fix that.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed it

// wait content_vec.len() seconds for data to propagate, giving more time if more items are propagating
tokio::time::sleep(Duration::from_secs(test_data.len() as u64)).await;

let (first_header_key, first_header_value) = test_data.get(0).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

It's worth adding a docstring to the code for reference

if let HistoryContentKey::BlockHeaderWithProof(_) = &content_key {
last_header_seen = (content_key.clone(), content_value.clone());
}
let comment =
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick something likecontent_details might be a more useful var name here

match client_b.rpc.local_content(content_key.clone()).await {
Ok(possible_content) => {
match possible_content {
match possible_content {
PossibleHistoryContentValue::ContentPresent(content) => {
if content != content_value {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know you didn't write this code, but could you update these var names to expected_key/expected_value and actual_key/actual_value. When doing comparisons on tested data, this kind of naming scheme makes it much simpler to figure out what's actually being tested, which var is the test data, etc.

content_type
)
} else {
unreachable!("History test dated is formatted incorrectly")
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just expand in this comment as to what most likely went wrong and caused the invalid formatting

@KolbyML KolbyML force-pushed the make-errors-auto-gen branch from e77e6b8 to c59bf1c Compare January 9, 2024 20:35
@KolbyML
Copy link
Member Author

KolbyML commented Jan 9, 2024

@njgheorghita I attempted to resolve the concerns, I was a little confused. So let me know what you think and hopefully we can get this in!

Copy link
Contributor

@njgheorghita njgheorghita left a comment

Choose a reason for hiding this comment

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

🚢

@KolbyML KolbyML merged commit f279cf2 into ethereum:main Jan 11, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants