-
Notifications
You must be signed in to change notification settings - Fork 36.8k
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
refactor: make setsockopt() and SetSocketNoDelay() mockable/testable #24357
refactor: make setsockopt() and SetSocketNoDelay() mockable/testable #24357
Conversation
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 |
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 aaf8d7e
Some style feedback, feel free to ignore.
aaf8d7e
to
3ee641f
Compare
Invalidates ACK from @jonatack |
ACK 3ee641f |
This will help to increase `Sock` usage and make more code mockable.
Since the former is mockable, this makes it easier to test higher level code that sets the TCP_NODELAY flag.
3ee641f
to
a2c4a7a
Compare
Invalidates ACK from @jonatack |
Code review ACK a2c4a7a |
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 a2c4a7a change since last review is folding Sock::SetNoDelay()
into the callers
…() mockable/testable a2c4a7a net: use Sock::SetSockOpt() instead of standalone SetSocketNoDelay() (Vasil Dimov) d65b6c3 net: use Sock::SetSockOpt() instead of setsockopt() (Vasil Dimov) 184e56d net: add new method Sock::SetSockOpt() that wraps setsockopt() (Vasil Dimov) Pull request description: _This is a piece of bitcoin#21878, chopped off to ease review._ Add a `virtual` (thus mockable) method `Sock::SetSockOpt()` that wraps the system `setsockopt()`. Convert the standalone `SetSocketNoDelay()` function to a `virtual` (thus mockable) method `Sock::SetNoDelay()`. This will help avoid syscalls during testing and to mock them to return whatever is suitable for the tests. ACKs for top commit: laanwj: Code review ACK a2c4a7a jonatack: ACK a2c4a7a change since last review is folding `Sock::SetNoDelay()` into the callers Tree-SHA512: 3e2b016c1e4128317a28c17dc9b30472949e1ac3b071b2697c6d30cbcc830df1ee4392a4e23b2ea1ab4e3fb0f59ef450e2a4f3c1df3d8c803dd081652b6c7387
This is a piece of #21878, chopped off to ease review.
Add a
virtual
(thus mockable) methodSock::SetSockOpt()
that wraps the systemsetsockopt()
.Convert the standalone
SetSocketNoDelay()
function to avirtual
(thus mockable) methodSock::SetNoDelay()
.This will help avoid syscalls during testing and to mock them to return whatever is suitable for the tests.