Synvael/crates/net/src/tests/endpoint.rs

25 lines
718 B
Rust

// SPDX-License-Identifier: AGPL-3.0-only
use super::*;
#[test]
fn alpn_identifier_is_synvael() {
assert_eq!(ALPN, b"synvael");
}
// A tokio runtime is required because `quinn::Endpoint` spawns its driver task on construction.
#[tokio::test]
async fn server_endpoint_constructs_and_binds() -> Result<(), NetError> {
let bind = "127.0.0.1:0".parse().map_err(std::io::Error::other)?;
let endpoint = server_endpoint(bind)?;
// A concrete port is assigned once the UDP socket is bound.
assert_ne!(endpoint.local_addr()?.port(), 0, "socket must bind a port");
Ok(())
}
#[tokio::test]
async fn client_endpoint_constructs_and_binds() -> Result<(), NetError> {
client_endpoint()?;
Ok(())
}