From d66bc272ad99e6afcf8a8d348244cbdd4875c40b Mon Sep 17 00:00:00 2001 From: Markus Pettersson Date: Fri, 5 Apr 2024 10:55:19 +0200 Subject: [PATCH] Avoid `unwrap` --- test/test-manager/src/network_monitor.rs | 7 ++++--- test/test-manager/src/tests/tunnel.rs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/test-manager/src/network_monitor.rs b/test/test-manager/src/network_monitor.rs index d47002eff883..ddd35edc7e9e 100644 --- a/test/test-manager/src/network_monitor.rs +++ b/test/test-manager/src/network_monitor.rs @@ -152,8 +152,9 @@ impl Codec { } } -#[derive(Debug)] -pub struct MonitorUnexpectedlyStopped(()); +#[derive(Debug, thiserror::Error)] +#[error("Packet monitor stopped unexpectedly")] +pub struct MonitorUnexpectedlyStopped; pub struct PacketMonitor { handle: tokio::task::JoinHandle>, @@ -305,7 +306,7 @@ async fn start_packet_monitor_for_interface( } _ => { log::error!("lost packet stream"); - break Err(MonitorUnexpectedlyStopped(())); + break Err(MonitorUnexpectedlyStopped); } } } diff --git a/test/test-manager/src/tests/tunnel.rs b/test/test-manager/src/tests/tunnel.rs index 1e21dfd4824d..f38b42a21a95 100644 --- a/test/test-manager/src/tests/tunnel.rs +++ b/test/test-manager/src/tests/tunnel.rs @@ -807,7 +807,7 @@ pub async fn test_mul_02_002( _: TestContext, rpc: ServiceClient, mut mullvad_client: MullvadProxyClient, -) -> Result<(), anyhow::Error> { +) -> anyhow::Result<()> { // Step 0 - Disconnect from any active tunnel connection helpers::disconnect_and_wait(&mut mullvad_client).await?; // Step 1 - Choose a relay @@ -862,7 +862,7 @@ pub async fn test_mul_02_002( let rogue_packet_monitor = start_packet_monitor(identify_rogue_packet, MonitorOptions::default()).await; conn_artist.check_connection().await?; - let monitor_result = rogue_packet_monitor.into_result().await.unwrap(); + let monitor_result = rogue_packet_monitor.into_result().await?; log::info!("Checking that the identifiable payload was not detected"); ensure!(