diff --git a/src/servers/udp/connection_cookie.rs b/src/servers/udp/connection_cookie.rs index a389388a..4dc9896a 100644 --- a/src/servers/udp/connection_cookie.rs +++ b/src/servers/udp/connection_cookie.rs @@ -314,7 +314,7 @@ mod tests { } #[test] - #[should_panic] + #[should_panic = "InvalidConnectionId"] fn it_should_be_not_valid_after_their_last_time_extent() { let remote_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 0); diff --git a/src/tracker/peer.rs b/src/tracker/peer.rs index 76747fea..d6517f21 100644 --- a/src/tracker/peer.rs +++ b/src/tracker/peer.rs @@ -150,7 +150,13 @@ impl Id { /// Will panic if byte slice does not contains the exact amount of bytes need for the `Id`. #[must_use] pub fn from_bytes(bytes: &[u8]) -> Self { - assert_eq!(bytes.len(), PEER_ID_BYTES_LEN); + assert_eq!( + PEER_ID_BYTES_LEN, + bytes.len(), + "we are testing the equality of the constant: `PEER_ID_BYTES_LEN` ({}) and the supplied `bytes` length: {}", + PEER_ID_BYTES_LEN, + bytes.len(), + ); let mut ret = Self([0u8; PEER_ID_BYTES_LEN]); ret.0.clone_from_slice(bytes); ret @@ -363,14 +369,14 @@ mod test { } #[test] - #[should_panic] + #[should_panic = "we are testing the equality of the constant: `PEER_ID_BYTES_LEN` (20) and the supplied `bytes` length: 19"] fn should_fail_trying_to_instantiate_from_a_byte_slice_with_less_than_20_bytes() { let less_than_20_bytes = [0; 19]; let _: peer::Id = peer::Id::from_bytes(&less_than_20_bytes); } #[test] - #[should_panic] + #[should_panic = "we are testing the equality of the constant: `PEER_ID_BYTES_LEN` (20) and the supplied `bytes` length: 21"] fn should_fail_trying_to_instantiate_from_a_byte_slice_with_more_than_20_bytes() { let more_than_20_bytes = [0; 21]; let _: peer::Id = peer::Id::from_bytes(&more_than_20_bytes); @@ -418,13 +424,13 @@ mod test { } #[test] - #[should_panic] + #[should_panic = "NotEnoughBytes"] fn should_fail_trying_to_convert_from_a_byte_vector_with_less_than_20_bytes() { let _: peer::Id = peer::Id::try_from([0; 19].to_vec()).unwrap(); } #[test] - #[should_panic] + #[should_panic = "TooManyBytes"] fn should_fail_trying_to_convert_from_a_byte_vector_with_more_than_20_bytes() { let _: peer::Id = peer::Id::try_from([0; 21].to_vec()).unwrap(); } diff --git a/tests/servers/api/v1/contract/configuration.rs b/tests/servers/api/v1/contract/configuration.rs index e4b60860..9ed257c5 100644 --- a/tests/servers/api/v1/contract/configuration.rs +++ b/tests/servers/api/v1/contract/configuration.rs @@ -3,7 +3,7 @@ use torrust_tracker_test_helpers::configuration; use crate::servers::api::test_environment::stopped_test_environment; #[tokio::test] -#[should_panic] +#[should_panic = "Could not receive bind_address."] async fn should_fail_with_ssl_enabled_and_bad_ssl_config() { let mut test_env = stopped_test_environment(configuration::ephemeral());