From e0dc77c57ea897c5898c7462b8de2e100d0e07af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=ADckolas=20Goline?= Date: Tue, 19 May 2026 10:34:05 -0300 Subject: [PATCH] tests: fix test_low_fd_limit failing on RLIM_INFINITY platforms 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. Changelog-None Co-Authored-By: Claude Sonnet 4.6 --- tests/test_misc.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/test_misc.py b/tests/test_misc.py index 4154ad6eba7f..ff97ceb13a4d 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -4925,8 +4925,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)