Skip to content

Replace lightning-block-sync test that depended on foo.com #2655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions lightning-block-sync/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,21 +511,19 @@ mod endpoint_tests {

#[test]
fn convert_to_socket_addrs() {
let endpoint = HttpEndpoint::for_host("foo.com".into());
let endpoint = HttpEndpoint::for_host("localhost".into());
let host = endpoint.host();
let port = endpoint.port();

use std::net::ToSocketAddrs;
match (&endpoint).to_socket_addrs() {
Err(e) => panic!("Unexpected error: {:?}", e),
Ok(mut socket_addrs) => {
match socket_addrs.next() {
None => panic!("Expected socket address"),
Some(addr) => {
assert_eq!(addr, (host, port).to_socket_addrs().unwrap().next().unwrap());
assert!(socket_addrs.next().is_none());
}
Ok(socket_addrs) => {
let mut std_addrs = (host, port).to_socket_addrs().unwrap();
for addr in socket_addrs {
assert_eq!(addr, std_addrs.next().unwrap());
}
assert!(std_addrs.next().is_none());
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we are assuming std_addrs contains at least one item? Probably fine but just want to call that out.

Copy link
Contributor

Choose a reason for hiding this comment

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

Otherwise, you need peekable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No? We only check that the two iterators are exactly equal, not that either contain anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, the old code made sure there was at least one with panic!("Expected socket address"). Without that, you may skip the check entirely if the size is zero, meaning the test isn't checking anything.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, yea, I don't think we need to check that. Like, in theory someone could have a horrendously misconfigured system where localhost doesn't resolve to anything. We shouldn't fail tests if that happens, though honestly I'm surprised that system is running and not randomly crashing in other places :)

}
}
}
Expand Down