Skip to content

Comments

fix: tests on MacOS#214

Merged
SeverinAlexB merged 2 commits intomainfrom
fix/MacOS-tests
Feb 12, 2026
Merged

fix: tests on MacOS#214
SeverinAlexB merged 2 commits intomainfrom
fix/MacOS-tests

Conversation

@SeverinAlexB
Copy link
Contributor

@SeverinAlexB SeverinAlexB commented Feb 11, 2026

Summary

  • Bind all test DHT nodes and clients to 127.0.0.1 instead of 0.0.0.0 to fix 46 test failures on macOS
  • Replace deprecated Testnet::new_async(N) / Testnet::new(N) with Testnet::builder(N).build() (defaults to localhost)
  • Add .bind_address(Ipv4Addr::LOCALHOST) to all test DhtBuilder configs

Context

On newer macOS, binding UDP sockets to 0.0.0.0 causes DHT nodes to become unreachable — the OS may route UDP responses through a different interface than loopback, resulting in NoClosestNodes and UnexpectedResponses errors. This caused 46 out of ~96 tests to fail.

Mainline 6.1.1 added Testnet::builder(N) which defaults bind_address to 127.0.0.1 (vs 0.0.0.0 in the legacy new() / new_async() constructors). This PR adopts that pattern across all pkarr tests, matching what mainline's own test suite does.

Changes

  • pkarr/src/client/tests.rs: Replaced all Testnet::new_async() calls with Testnet::builder().build(), added .dht(|b| b.bind_address(Ipv4Addr::LOCALHOST)) to the shared builder() helper and standalone client builders
  • pkarr/src/extra/endpoints/mod.rs: Same pattern for all 5 endpoint tests
  • relay/src/lib.rs: Added bind_address(LOCALHOST) to run_test() and run_testnet(), replaced Testnet::new() with Testnet::builder().build()

See pubky/mainline#82

Copy link
Contributor

@afterburn afterburn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SeverinAlexB lgtm, one small nit but feel free to ignore

@SeverinAlexB SeverinAlexB merged commit f704456 into main Feb 12, 2026
9 checks passed
@SeverinAlexB SeverinAlexB mentioned this pull request Feb 16, 2026
@SeverinAlexB SeverinAlexB deleted the fix/MacOS-tests branch February 17, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants