Make connect_with_unknown_server actually connect to unknown server
What changed, and why it matters
This is a minor fix to a single automated test. The test previously assumed port 80 was unused, which failed on machines running a web server like Apache. The change finds an unused local port instead. It does not affect production code or user-facing behavior.
No security action needed. This is a test-only reliability improvement and can be treated as routine maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies lightning-block-sync/src/http.rs in the connect_with_unknown_server unit test. It replaces a hardcoded connection to ("::", 80) with a dynamically discovered unused port obtained by binding TcpListener to ("127.0.0.1", 0). The test logic remains identical; only the target port is now reliable across different developer environments.
Changed components
lightning-block-sync/src/http.rsunit test `connect_with_unknown_server`Inspect captured patch +7 / −1
diff --git a/lightning-block-sync/src/http.rs b/lightning-block-sync/src/http.rs
index c230b25..0fb82b4 100644
--- a/lightning-block-sync/src/http.rs
+++ b/lightning-block-sync/src/http.rs
@@ -710,7 +710,13 @@ pub(crate) mod client_tests {
#[test]
fn connect_with_unknown_server() {
- match HttpClient::connect(("::", 80)) {
+ // get an unused port by binding to port 0
+ let port = {
+ let t = std::net::TcpListener::bind(("127.0.0.1", 0)).unwrap();
+ t.local_addr().unwrap().port()
+ };
+
+ match HttpClient::connect(("::", port)) {
#[cfg(target_os = "windows")]
Err(e) => assert_eq!(e.kind(), std::io::ErrorKind::AddrNotAvailable),
#[cfg(not(target_os = "windows"))]
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.