tests: fix test_low_fd_limit failing on RLIM_INFINITY platforms
Some checks failed
Continuous Integration / Pre-build checks (push) Has been cancelled
Release Rust 🦀 / release_rust (push) Has been cancelled
Continuous Integration / Build compile-clang-sanitizers (push) Has been cancelled
Continuous Integration / Build compile-clang (push) Has been cancelled
Continuous Integration / Build compile-gcc (push) Has been cancelled
Continuous Integration / Build compile-gcc-O1 (push) Has been cancelled
Continuous Integration / Build compile-gcc-O3 (push) Has been cancelled
Continuous Integration / check-compiled-source (compile-gcc) (push) Has been cancelled
Continuous Integration / Run unit tests (push) Has been cancelled
Continuous Integration / Run unit tests-1 (push) Has been cancelled
Continuous Integration / Build 32-bit (size_t != 64-bit warnings) (push) Has been cancelled
Continuous Integration / Run fuzz regression tests (push) Has been cancelled
Continuous Integration / Check we can downgrade the node (push) Has been cancelled
Continuous Integration / Check we can downgrade the node-1 (push) Has been cancelled
Continuous Integration / Check we can downgrade the node-2 (push) Has been cancelled
Continuous Integration / First Integration Tests (1/6) (push) Has been cancelled
Continuous Integration / First Integration Tests (2/6) (push) Has been cancelled
Continuous Integration / First Integration Tests (3/6) (push) Has been cancelled
Continuous Integration / First Integration Tests (4/6) (push) Has been cancelled
Continuous Integration / First Integration Tests (5/6) (push) Has been cancelled
Continuous Integration / First Integration Tests (6/6) (push) Has been cancelled
Continuous Integration / Test CLN dual-fund Full Integration (push) Has been cancelled
Continuous Integration / Test CLN liquid Full Integration (push) Has been cancelled
Continuous Integration / Test CLN postgres Full Integration (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (1/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (10/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (11/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (12/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (2/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (3/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (4/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (5/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (6/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (7/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (8/12) (push) Has been cancelled
Continuous Integration / Valgrind Test CLN (9/12) (push) Has been cancelled
Continuous Integration / ASan/UBSan (1/6) (push) Has been cancelled
Continuous Integration / ASan/UBSan (2/6) (push) Has been cancelled
Continuous Integration / ASan/UBSan (3/6) (push) Has been cancelled
Continuous Integration / ASan/UBSan (4/6) (push) Has been cancelled
Continuous Integration / ASan/UBSan (5/6) (push) Has been cancelled
Continuous Integration / ASan/UBSan (6/6) (push) Has been cancelled
Continuous Integration / Update examples in doc schemas (push) Has been cancelled
Continuous Integration / Test minimum supported BTC v25.0 with clang (push) Has been cancelled
Continuous Integration / CI completion (push) Has been cancelled

When RLIMIT_NOFILE hard limit is RLIM_INFINITY (macOS default) or
larger than UINT32_MAX, passing limits[1] and limits[1]+1 directly as
--dev-fd-limit-multiplier (a u32 option) causes lightningd to reject
the argument as out-of-range and exit(1), making both nodes fail to
start with "Unable to find Server started with public key" timeout.

Cap to TEST_CEILING=65536 when the hard limit is RLIM_INFINITY or
exceeds the ceiling, keeping the existing soft==hard halving path for
normal bounded limits.

Also add the test to the macOS CI list, so the platform it was broken
on now covers it.

Changelog-None
This commit is contained in:
Níckolas Goline 2026-05-19 10:34:05 -03:00 committed by daywalker90
parent 39b7f6dfbd
commit ae53e8775e
2 changed files with 11 additions and 2 deletions

View file

@ -60,6 +60,7 @@ jobs:
PYTEST_OPTS: "-vvv --timeout=1800 --durations=10"
PYTEST_TESTS: |
tests/test_misc.py::test_ipv4_and_ipv6
tests/test_misc.py::test_low_fd_limit
tests/test_connection.py::test_websocket
tests/test_connection.py::test_wss_proxy
tests/test_plugin.py::test_inline_plugin_wait_for_log_no_selfmatch

View file

@ -4998,8 +4998,16 @@ def test_set_feerate_offset(node_factory, bitcoind):
def test_low_fd_limit(node_factory, bitcoind):
limits = resource.getrlimit(resource.RLIMIT_NOFILE)
# We assume this, otherwise l2 cannot increase limits!
if limits[0] == limits[1]:
# dev-fd-limit-multiplier is a u32, so values > UINT32_MAX fail option
# parsing. macOS also reports RLIM_INFINITY as the hard limit, making
# "ask for more than the hard limit" meaningless. Cap to a bounded
# ceiling so the test works on any platform.
TEST_CEILING = 65536
if limits[1] == resource.RLIM_INFINITY or limits[1] > TEST_CEILING:
limits = (TEST_CEILING // 2, TEST_CEILING)
resource.setrlimit(resource.RLIMIT_NOFILE, limits)
elif limits[0] == limits[1]:
# We assume this, otherwise l2 cannot increase limits!
limits = (limits[1] // 2, limits[1])
resource.setrlimit(resource.RLIMIT_NOFILE, limits)