Skip to content

Commit

Permalink
Avoid unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Apr 9, 2024
1 parent 073de11 commit d66bc27
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions test/test-manager/src/network_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Result<MonitorResult, MonitorUnexpectedlyStopped>>,
Expand Down Expand Up @@ -305,7 +306,7 @@ async fn start_packet_monitor_for_interface(
}
_ => {
log::error!("lost packet stream");
break Err(MonitorUnexpectedlyStopped(()));
break Err(MonitorUnexpectedlyStopped);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/test-manager/src/tests/tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!(
Expand Down

0 comments on commit d66bc27

Please sign in to comment.