Skip to content

Commit 18f4e48

Browse files
authored
Merge pull request #4034 from benthecarman/block-sync-test-port
Make connect_with_unknown_server actually connect to unknown server
2 parents bbfc694 + 38c5b70 commit 18f4e48

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lightning-block-sync/src/http.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,13 @@ pub(crate) mod client_tests {
710710

711711
#[test]
712712
fn connect_with_unknown_server() {
713-
match HttpClient::connect(("::", 80)) {
713+
// get an unused port by binding to port 0
714+
let port = {
715+
let t = std::net::TcpListener::bind(("127.0.0.1", 0)).unwrap();
716+
t.local_addr().unwrap().port()
717+
};
718+
719+
match HttpClient::connect(("::", port)) {
714720
#[cfg(target_os = "windows")]
715721
Err(e) => assert_eq!(e.kind(), std::io::ErrorKind::AddrNotAvailable),
716722
#[cfg(not(target_os = "windows"))]

0 commit comments

Comments
 (0)