refactor: make bind() and listen() mockable/testable#24378
refactor: make bind() and listen() mockable/testable#24378laanwj merged 2 commits intobitcoin:masterfrom
Conversation
There was a problem hiding this comment.
Concept ACK
I'm not too familiar on fuzzing and setting errno. May I ask what is the rationale for choosing the errno arrays in the fuzz tests? According to the linux manpages, there are some more possible errno vaues that bind and listen could set:
https://man7.org/linux/man-pages/man2/bind.2.html (EACCES, EADDRINUSE, EBADF, EINVAL, ENOTSOCK)
https://man7.org/linux/man-pages/man2/listen.2.html (EADDRINUSE, EBADF, ENOTSOCK, EOPNOTSUPP)
Note that there's a typo in the PR title: s/mockatble/mockable/
Not much, other than the first one must be a permanent error in order to avoid infinite loops in case the app code decides to retry on bitcoin/src/test/fuzz/util.cpp Lines 78 to 80 in c9ed992 I think it is good to have both temporary errors (e.g. Line 28 in c9ed992 Line 1677 in c9ed992 I added the comments and |
5249fc7 to
c2f80ba
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. |
|
ACK c2f80ba98d2b4cd8b1ded6f507cd457de05a7884 |
This will help to increase `Sock` usage and make more code mockable.
This will help to increase `Sock` usage and make more code mockable.
c2f80ba to
b2733ab
Compare
|
|
|
ACK b2733ab |
|
|
||
| // Listen for incoming connections | ||
| if (listen(sock->Get(), SOMAXCONN) == SOCKET_ERROR) | ||
| if (sock->Listen(SOMAXCONN) == SOCKET_ERROR) |
There was a problem hiding this comment.
if you retouch, maybe fix up the bracket here like you did above
You mean in |
|
Code review ACK b2733ab |
…able b2733ab net: add new method Sock::Listen() that wraps listen() (Vasil Dimov) 3ad7de2 net: add new method Sock::Bind() that wraps bind() (Vasil Dimov) Pull request description: _This is a piece of bitcoin#21878, chopped off to ease review._ Add new methods `Sock::Bind()` and `Sock::Listen()` that wrap `bind()` and `listen()`. This will help to increase `Sock` usage and make more code mockable. ACKs for top commit: pk-b2: ACK b2733ab laanwj: Code review ACK b2733ab Tree-SHA512: c6e737606703e2106fe60cc000cfbbae3a7f43deadb25f70531e2cac0457e0b0581440279d14c76c492eb85c12af4adde52c30baf74542c41597e419817488e8
This is a piece of #21878, chopped off to ease review.
Add new methods
Sock::Bind()andSock::Listen()that wrapbind()andlisten().This will help to increase
Sockusage and make more code mockable.