Skip to content

net: build the test suite on macOS - #1184

Merged
reardencode merged 1 commit into
reardencode:masterfrom
smolcars:fix/net-test-libc-macos
Oct 24, 2026
Merged

reardencode merged 1 commit into
reardencode:masterfrom
smolcars:fix/net-test-libc-macos

Conversation

@niteshbalusu11

@niteshbalusu11 niteshbalusu11 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1179.

The net test suite did not compile on macOS. tests/i2p_sam.rs uses libc under cfg(unix), but libc was a Linux-only dependency.

  • Add libc as a cfg(unix) dev-dependency. The SAM reset test keeps running on macOS.
  • Gate snapshot_omits_peer_after_tcp_fin to Linux. It needs POLLRDHUP. Off Linux, tcp_has_peer_fin always returns false.

Checked on macOS: workspace clippy passes. The full net suite ran 635 of 636; the one failure is the flake below.

Seen once on macOS under full-suite load: tip_accept::two_full_senders_both_enqueue failed with "queued 1". It passed 5 of 5 runs alone. Not touched here.

🤖 Generated with Claude Code

tests/i2p_sam.rs calls libc under cfg(unix), but libc was only a Linux
dependency. Add it as a cfg(unix) dev-dependency so the RST path still
runs on macOS.

snapshot_omits_peer_after_tcp_fin needs POLLRDHUP, which only Linux has.
Off Linux tcp_has_peer_fin always returns false, so gate the test to Linux.

Fixes reardencode#1179

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@niteshbalusu11

Copy link
Copy Markdown
Contributor Author

The coverage failure is the end_of_ibd_sh_interrupt flake, tracked in #1185. It is not from this change. Could a maintainer rerun the coverage job? I can't rerun it from the fork.

@rearden-grok rearden-grok Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict

APPROVE. I would merge this as-is.

The change makes rbitcoin-net's integration suite compile on non-Linux Unix. Production code is unchanged. The Linux unread-FIN test still runs. libc is the existing workspace crate, dev-only, at the same 0.2 requirement, and Cargo.lock stays put.

Findings

Pre-existing, not blocking

tcp_has_peer_fin is Linux-only and returns false on every other OS. LivePeer::tcp_fin then peeks one byte. A graceful FIN that still has unread data comes back as Ok(1), so PeerHub::snapshot keeps a handshake-complete peer. That is the case snapshot_omits_peer_after_tcp_fin pins, and it is the getpeerinfo drop Core's disconnect_nodes 5s window depends on. Darwin is a shipped target and has no POLLRDHUP. kqueue EVFILT_READ with EV_EOF can observe this; this PR does not add that.

The new #[cfg(target_os = "linux")] matches the production cfg, so the test still runs on every platform where the current implementation can pass. Empty-buffer FIN stays covered on every OS by snapshot_hides_fin_completed_keeps_connecting. Peek still treats Ok(0) as FIN, and any error other than WouldBlock or Interrupted (including reset) as a dead socket.

Nits

None.

What was built and tested

Head 97d94bb0c2deeeaeed83b8fc0fcf340366860d13, merge-base 8e62e4ce4d60c30abc851cb0893e4b80149ac9e4 (origin/master). Diff is crates/rbitcoin-net/Cargo.toml (+4) and crates/rbitcoin-net/tests/peer/mod.rs (+2).

Supply chain: libc = "0.2" matches rbitcoin-store, rbitcoin-node (cfg(unix)), and rbitcoin-ibd. No features added. Lock stays libc 0.2.191. cargo tree --locked direct edges: Darwin has dev libc 0.2.191; Windows has no direct libc; Linux has both the normal edge and the dev edge, both 0.2.191. --locked resolution succeeded.

  • cargo fmt --all -- --check: pass
  • cargo test --locked -p rbitcoin-net --test suite -- --quiet: 637 passed, 0 failed, 16.18s (includes snapshot_omits_peer_after_tcp_fin and the i2p_sam tests)
  • snapshot_hides_fin_completed_keeps_connecting: pass
  • cargo clippy --locked -p rbitcoin-net --all-targets -- -D warnings: pass

This box is Linux. cargo check --target aarch64-apple-darwin did not get a typecheck: secp256k1-sys failed in-environment because the host cc has no macOS SDK. The Darwin libc edge above is from cargo tree, not from a Darwin rustc run. The author's macOS report (suite 635/636, one tip_accept::two_full_senders_both_enqueue flake) did not show up in this Linux full-suite run.

The required macos CI job still runs scripts/ci-os-smoke.sh only, so it will not compile this suite. That matches #1179 and is unchanged.

@reardencode
reardencode merged commit 4096982 into reardencode:master Oct 24, 2026
24 of 25 checks passed
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.

net: tests/suite does not compile on macOS (libc is Linux-only)

2 participants