-
Notifications
You must be signed in to change notification settings - Fork 35.7k
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: Disable automatic connections per default in the functional tests #22490
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
Concept ACK |
b5fb65b
to
b637481
Compare
Any reason to not disable this globally? See also fa730e9 |
To expand on the last sentence of the OP (I tried disabling this globally by adding
|
There could be one (unit or function) test to call it?
There could be a option passed to
See above |
Thanks, good idea! I'll try this, might be a couple of days until I'll get to it, will change to draft until then. |
concept ACK |
Super Strong Concept ACK The act of running the test suite should never cause any communication with the outside world, and certainly not cause TCP connections to random computers on the Internet :) |
This prevents the node from trying to connect to random IPs on the internet while running the functional tests. Exceptions are added when required for the test to pass.
b637481
to
8ca51af
Compare
As suggested by @MarcoFalke, I now reversed the logic to disable automatic connections by default and add exceptions only when required ( |
Concept ACK, light code review ACK 8ca51af |
@mzumsande- did you consider the approach of adding I'm thinking something like
When looking at #22098 (comment), I realized that test doesn't actually need rebase or an exception added, because passing in something like So this means the tests setting I think my proposed alternative could simplify the test framework code (don't have to pass around the What do you think? |
hm, I think my suggestion ☝️ does not work for the tests that hit normal automatic connections logic in so setting as a command line arg instead of in the conf file is still an option, but we'd need an additional field regardless. still could be nice to have more straightforward logs (instead of having two |
Sorry for not answering sooner - I had shortly thought about this option before creating this PR, but thought it would fit in better in
I agree, it wouldn't work for tests like So with the upside of having the networking command-line args in one place, and the downside of having two log items, I don't have a strong preference here. |
Agreed, let's leave it as is. Thanks! |
Summary: ``` This prevents the node from trying to connect to random IPs on the internet while running the functional tests. Exceptions are added when required for the test to pass. ``` Backport of [[bitcoin/bitcoin#22490 | core#22490]]. Ref T1696. Test Plan: ninja all check-all Reviewers: #bitcoin_abc, PiRK Reviewed By: #bitcoin_abc, PiRK Maniphest Tasks: T1696 Differential Revision: https://reviews.bitcoinabc.org/D10966
A node normally doesn't make automatic connections to peers in the functional tests because neither DNS seeds nor hardcoded peers are available on regtest. However, when random entries are inserted into addrman as part of a functional test (e.g. while testing addr relay),
ThreadOpenConnections
will periodically try to connect to them, resulting in log entries such as:[opencon] [net.cpp:400] [ConnectNode] trying connection 18.166.1.1:8333 lastseen=0.0hrs
I don't think it's desirable that functional tests try to connect to random computers on the internet, aside from the possibility that at some point in time someone out there might actually answer in a way to ruin a test.
This PR fixes this problem by disabling
ThreadOpenConnections
by adding-connect=0
to the default args, and adding exceptions only when needed for the test to pass.