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
test: Extends wait_for_getheaders so a specific block hash can be checked #29736
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
I've added a default case for |
e72e941
to
402d7fe
Compare
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
402d7fe
to
dee61c8
Compare
Something that may be worth discussing is whether we want to assert that the desired block hash is within the hashes reported on the For the patched tests, I've made sure that it was the case it matched the closest to the tip, but its parent would also have made the test pass. |
912ae78
to
3520d28
Compare
Concept ACK 3520d28 just an observation, It seems like we only use
If we're looking for the |
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.
lgtm
Partially fixes #18614
I think this fully solves the remainder, or is something left to be done afterwards?
You're right, I thought there may be other methods that also needed patching (and didn't check that was not the case 😅 ). I'm working on a cleanup PR for things that were left out after #18690, but that should be unrelated |
Concept ACK |
Yeah, that's done on purpose. The
That could imply that the test is wrong. The current approach is more permissive, but it means that a test could pass unexpectedly. e.g; Imagine our current chain looks like this:
We wait to receive a
In this case, the test will pass because our expected hash is within the received hashes, but likely the test should have waited for It really depends on what we want to check, and the flexibility we want to give to the method though |
3520d28
to
247c5a5
Compare
247c5a5
to
fb9eb7a
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.
crACK fb9eb7a
I just tried with |
Yeah, for all patched tests I"ve made sure that was the case. The question was more if generally that would be the expected case |
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.
yay, nice! just 1 question, will ACK after that.
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.
Something that may be worth discussing is whether we want to assert that the desired block hash is within the hashes reported on the getheaders message (current approach), or if we want to make sure it matches the first one (i.e. the closest to the tip).
For the patched tests, I've made sure that it was the case it matched the closest to the tip, but its parent would also have made the test pass.
i prefer the stricter option since i'd want tests written in the future to be aware of those unexpected passes. if we don't care about the exact content of header, there is the block_hash=None
variant anyways.
looks like this |
af5d494
to
80ec483
Compare
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the Possibly this is due to a silent merge conflict (the changes in this pull request being Leave a comment here, if you need help tracking down a confusing failure. |
Thanks for the thorough review @stratospher
I've done it in 80ec483. Given we are reusing the same test node throughout the whole file and the state of what block may be expected is not clean, I waited for the message to be seen, but without any expected block check (this should be safe now that we pop the content of the dict). Also:
|
…thods that use it 61560d5 test: makes timeout a forced named argument in tests methods that use it (Sergi Delgado Segura) Pull request description: This makes calls to such methods more explicit and less error-prone. Motivated by #29736 (comment) ACKs for top commit: maflcko: lgtm ACK 61560d5 brunoerg: ACK 61560d5 BrandonOdiwuor: crACK 61560d5 AngusP: ACK 61560d5 stratospher: tested ACK 61560d5. Tree-SHA512: 8d6ec3fe1076c868ddbd3050f3c242dbd83cc123f560db3d3b0ed74968e6050dc9ebf4e7c716af9cc1b290c97d736c2fc2ac936b0b69ebdbceed934dae7d55d9
80ec483
to
4b4df27
Compare
Rebased to include the changes from #29750 and cover #29736 (comment) |
4b4df27
to
8adac64
Compare
8adac64
to
9cb89d6
Compare
…cked Previously, `wait_for_getheaders` would check whether a node had received **any** getheaders message. This implied that, if a test needed to check for a specific block hash within a headers message, it had to make sure that it was checking the desired message. This normally involved having to manually clear `last_message`. This method, apart from being too verbose, was error prone, given an undesired `getheaders` would make tests pass. This adds the ability to check for a specific block_hash within the last `getheaders` message.
9cb89d6
to
c4f857c
Compare
I wonder if it may be worth splitting the This way we would get rid of a bunch of manual checks like: with p2p_lock:
assert "getheaders" not in peer.last_message cc/ @maflcko @stratospher |
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.
crACK c4f857c
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.
ACK c4f857c
Nice to see the TODO in p2p.py
resolved!
Searched through source for "getheaders" to make sure the function had been applied when suitable.
Reasoned through the modified test functions.
Modifications look good taking into account the new behavior of wait_for_getheaders()
popping off the message and requiring the block hash to match the top one if provided.
Built and ran functional tests with --extended --exclude=feature_dbcrash
with no failures (after cherry-picking 49c0b8b from #29791 on top of this PR to bump timeouts in 2 tests not touched in this PR).
Nit: Commit message subject is 73 chars long
CONTRIBUTING.md
links https://chris.beams.io/posts/git-commit/ which states "consider 72 the hard limit". It further suggests using an "Imperative mood", so you could just change "Extends" -> "Extend" and be done with it.
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.
tested ACK c4f857c. went through all getheaders messages sent in the tests and checked that it's the one we want.
ACK c4f857c |
This was never discussed btw, and I wonder if it is worth a followup |
Fixes #18614
Previously,
wait_for_getheaders
would check whether a node had received any getheaders message. This implied that, if a test needed to check for a specific block hash within a headers message, it had to make sure that it was checking the desired message. This normally involved having to manually clearlast_message
. This method, apart from being too verbose, was error-prone, given an undesiredgetheaders
would make tests pass.This adds the ability to check for a specific block_hash within the last
getheaders
message.