Skip to main content

xwt_tests/tests/
connect_rejected.rs

1//! This test ensures that a session that the server refuses to accept is
2//! reported as a connection failure rather than as a connected session.
3
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    #[error("connect has not failed")]
7    ConnectDidNotFail,
8}
9
10pub async fn run<Endpoint>(endpoint: Endpoint, url: &str) -> Result<(), Error>
11where
12    Endpoint: xwt_core::endpoint::Connect + std::fmt::Debug,
13    Endpoint::Connecting: std::fmt::Debug,
14{
15    let result = crate::utils::connect(&endpoint, url).await;
16
17    let Err(error) = result else {
18        return Err(Error::ConnectDidNotFail);
19    };
20
21    tracing::info!(message = "the error on the rejected connect was", %error);
22
23    Ok(())
24}