Skip to content

Commit

Permalink
mysten-network: default to http if not present
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed Jul 5, 2024
1 parent 902107f commit dab73eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
11 changes: 4 additions & 7 deletions crates/mysten-network/src/multiaddr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,10 @@ pub(crate) fn parse_tcp<'a, T: Iterator<Item = Protocol<'a>>>(protocols: &mut T)
pub(crate) fn parse_http_https<'a, T: Iterator<Item = Protocol<'a>>>(
protocols: &mut T,
) -> Result<&'static str> {
match protocols
.next()
.ok_or_else(|| eyre!("unexpected end of multiaddr"))?
{
Protocol::Http => Ok("http"),
Protocol::Https => Ok("https"),
_ => Err(eyre!("expected http/https protocol")),
match protocols.next() {
Some(Protocol::Http) => Ok("http"),
Some(Protocol::Https) => Ok("https"),
_ => Ok("http"),
}
}

Expand Down
7 changes: 0 additions & 7 deletions crates/mysten-network/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,6 @@ mod test {
test_multiaddr(address).await;
std::fs::remove_file(path).unwrap();
}

#[should_panic]
#[tokio::test]
async fn missing_http_protocol() {
let address: Multiaddr = "/dns/localhost/tcp/0".parse().unwrap();
test_multiaddr(address).await;
}
}

#[derive(Clone)]
Expand Down

0 comments on commit dab73eb

Please sign in to comment.