Merge bitcoin/bitcoin#31537: qa: Limit -maxconnections in tests

d9d5bc2e74 qa: Limit `-maxconnections` in tests (Hennadii Stepanov)

Pull request description:

  On systems such as NetBSD, the `bitcoind` typically prints the following warning:
  ```
  Warning: Reducing -maxconnections from 125 to 96, because of system limitations.
  ```

  This breaks the functional test framework (see https://github.com/bitcoin/bitcoin/issues/23968).

  This PR limits the `-maxconnections` to mitigate the issue and enable functional tests on NetBSD.

  Fixes https://github.com/bitcoin/bitcoin/issues/23968.

  Here is CI log from the [`bitcoin-core-nightly`](https://github.com/hebasto/bitcoin-core-nightly) repository: https://github.com/hebasto/bitcoin-core-nightly/actions/runs/12415868523/job/34663207030

ACKs for top commit:
  maflcko:
    re-ACK d9d5bc2e74
  achow101:
    ACK d9d5bc2e74
  mzumsande:
    Code Review ACK d9d5bc2e74
  tdb3:
    tested ACK d9d5bc2e74

Tree-SHA512: ad02adce98ce609176c9688289a0ca347932da5b6f259c6ab4e686914352f3d61f819adc150be80220f969200ee6a0c1c8737426525816fa0df58d688c51410c
This commit is contained in:
Ava Chow 2024-12-30 14:34:22 -05:00
commit fa3de038f7
No known key found for this signature in database
GPG key ID: 17565732E08E5E41

View file

@ -453,6 +453,17 @@ def write_config(config_path, *, n, chain, extra_config="", disable_autoconnect=
f.write("unsafesqlitesync=1\n")
if disable_autoconnect:
f.write("connect=0\n")
# Limit max connections to mitigate test failures on some systems caused by the warning:
# "Warning: Reducing -maxconnections from <...> to <...> due to system limitations".
# The value is calculated as follows:
# available_fds = 256 // Same as FD_SETSIZE on NetBSD.
# MIN_CORE_FDS = 151 // Number of file descriptors required for core functionality.
# MAX_ADDNODE_CONNECTIONS = 8 // Maximum number of -addnode outgoing nodes.
# nBind == 3 // Maximum number of bound interfaces used in a test.
#
# min_required_fds = MIN_CORE_FDS + MAX_ADDNODE_CONNECTIONS + nBind = 151 + 8 + 3 = 162;
# nMaxConnections = available_fds - min_required_fds = 256 - 161 = 94;
f.write("maxconnections=94\n")
f.write(extra_config)