Skip to content

Commit 631f989

Browse files
committed
Replace lightning-block-sync test that depended on foo.com
Our tests should generally not rely on internet access, and should not rely on the behavior of any given remote server. However, one of the `endpoint_tests` in `lightning-block-sync::http` relied on `foo.com` resolving to a single socket address, which both might change in the future and makes our tests fail without internet.
1 parent eea19de commit 631f989

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lightning-block-sync/src/http.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -511,21 +511,19 @@ mod endpoint_tests {
511511

512512
#[test]
513513
fn convert_to_socket_addrs() {
514-
let endpoint = HttpEndpoint::for_host("foo.com".into());
514+
let endpoint = HttpEndpoint::for_host("localhost".into());
515515
let host = endpoint.host();
516516
let port = endpoint.port();
517517

518518
use std::net::ToSocketAddrs;
519519
match (&endpoint).to_socket_addrs() {
520520
Err(e) => panic!("Unexpected error: {:?}", e),
521-
Ok(mut socket_addrs) => {
522-
match socket_addrs.next() {
523-
None => panic!("Expected socket address"),
524-
Some(addr) => {
525-
assert_eq!(addr, (host, port).to_socket_addrs().unwrap().next().unwrap());
526-
assert!(socket_addrs.next().is_none());
527-
}
521+
Ok(socket_addrs) => {
522+
let mut std_addrs = (host, port).to_socket_addrs().unwrap();
523+
for addr in socket_addrs {
524+
assert_eq!(addr, std_addrs.next().unwrap());
528525
}
526+
assert!(std_addrs.next().is_none());
529527
}
530528
}
531529
}

0 commit comments

Comments
 (0)