-
Notifications
You must be signed in to change notification settings - Fork 38.7k
p2p: Make timeout mockable and type safe, speed up test #19499
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
Conversation
fa64f6a to
fa1bfbe
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
|
Concept ACK: mockable is good |
|
Doesn't this defeat the purpose of the test? |
|
Concept ACK. There's a lot of refactor/tidyup in this PR. I wonder if that can be split out to make this more focused on the functional changes. |
fa1bfbe to
7a80cbf
Compare
d7d77a6 to
fae77a5
Compare
Good idea. Split up a scripted-diff as the first commit. |
This is a bugfix for the test. Currently it intermittently fails, see OP. |
fae77a5 to
fa166da
Compare
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s/\<$1\>/$2/g" $(git grep -l "$1" ./src) ; }
ren nLastSend m_last_send
ren nLastRecv m_last_recv
-END VERIFY SCRIPT-
fa166da to
faf3616
Compare
mzumsande
left a comment
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.
Concept ACK
Reviewed the non-GUI-related parts so far and played with p2p_timeouts.py - looks good to me, just some nits.
src/net.cpp
Outdated
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.
Why sometimes .count() and sometimes count_seconds()?
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.
last_recv is a bit like std::optional. I use .count(), when .has_value() would be used and I use count_seconds(), when .value() would be used.
faf3616 to
fadc0c8
Compare
| peer.m_ping_nonce_sent && | ||
| now > peer.m_ping_start.load() + std::chrono::seconds{TIMEOUT_INTERVAL}) { | ||
| now > peer.m_ping_start.load() + TIMEOUT_INTERVAL) | ||
| { |
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.
More consistent to keep the { on the same line?
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.
I think (and other seem to agree, see #21735) that multiline if conditions are hard to read because there is no break between condition and body, so changed it here.
Happy to revert, though.
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.
I don't particularly want to get into discussion about code style, it just seemed inconsistent to me (as all other if cases have the { on the same line), if you have a good reason for it it's fine with me.
|
Code review ACK fadc0c8 |
|
ACK fadc0c8 |
…, speed up test bc55c30 p2p: Make timeout mockable and type safe, speed up test (MarcoFalke) fdc1c9d scripted-diff: Rename m_last_send and m_last_recv (MarcoFalke) Pull request description: Use type-safe time for better code readability/maintainability and mockable time for better testability. This speeds up the p2p_timeout test. This is also a bugfix for intermittent test issues like: https://cirrus-ci.com/task/4769904156999680?command=ci#L2836 Fixes #20654 ACKs for top commit: laanwj: Code review ACK bc55c30 naumenkogs: ACK bc55c30 Tree-SHA512: 28c6544c97f188c8a0fbc80411c74ab74ffd055885322c325aa3d1c404b29c3fd70a737e86083eecae58ef394db1cb56bc122d06cff63742aa89a8e868730c64
Summary:
```
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s/\<$1\>/$2/g" $(git grep -l "$1" ./src) ; }
ren nLastSend m_last_send
ren nLastRecv m_last_recv
-END VERIFY SCRIPT-
```
This is a backport of [[bitcoin/bitcoin#19499 | core#19499]] [1/2]
bitcoin/bitcoin@fa6d5a2
Test Plan: `ninja all check-all`
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D10954
Use type-safe time for better code readability/maintainability and mockable time for better testability. This speeds up the p2p_timeout test.
This is also a bugfix for intermittent test issues like: https://cirrus-ci.com/task/4769904156999680?command=ci#L2836
Fixes #20654