p2p: Make timeout mockable and type safe, speed up test#19499
p2p: Make timeout mockable and type safe, speed up test#19499maflcko merged 2 commits intobitcoin:masterfrom
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.
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.
Why sometimes .count() and sometimes count_seconds()?
There was a problem hiding this comment.
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.
More consistent to keep the { on the same line?
There was a problem hiding this comment.
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.
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