From 8bd62181f76f786e9330927b7066dba75658a776 Mon Sep 17 00:00:00 2001 From: Markus Pettersson Date: Fri, 15 Nov 2024 08:21:37 +0100 Subject: [PATCH] Return error from `get_tunnel_interface` to ease error propagation --- test/test-manager/src/tests/audits/mllvd_cr_24_03.rs | 2 +- test/test-manager/src/tests/helpers.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/test/test-manager/src/tests/audits/mllvd_cr_24_03.rs b/test/test-manager/src/tests/audits/mllvd_cr_24_03.rs index ed3d2337d281..bf743bcc676d 100644 --- a/test/test-manager/src/tests/audits/mllvd_cr_24_03.rs +++ b/test/test-manager/src/tests/audits/mllvd_cr_24_03.rs @@ -45,7 +45,7 @@ pub async fn test_mllvd_cr_24_03( connect_and_wait(&mut mullvad_client).await?; // Get the private ip address let in_tunnel_ip = { - let vpn_interface = get_tunnel_interface(&mut mullvad_client).await.unwrap(); // :cat-scream: + let vpn_interface = get_tunnel_interface(&mut mullvad_client).await?; rpc.get_interface_ip(vpn_interface).await? }; // Invoke arping diff --git a/test/test-manager/src/tests/helpers.rs b/test/test-manager/src/tests/helpers.rs index 0c3f16ccb32b..84945aef795c 100644 --- a/test/test-manager/src/tests/helpers.rs +++ b/test/test-manager/src/tests/helpers.rs @@ -168,12 +168,15 @@ pub async fn using_mullvad_exit(rpc: &ServiceClient) -> bool { } /// Get VPN tunnel interface name -pub async fn get_tunnel_interface(client: &mut MullvadProxyClient) -> Option { - match client.get_tunnel_state().await.ok()? { +pub async fn get_tunnel_interface(client: &mut MullvadProxyClient) -> anyhow::Result { + match client.get_tunnel_state().await? { TunnelState::Connecting { endpoint, .. } | TunnelState::Connected { endpoint, .. } => { - endpoint.tunnel_interface + let Some(tunnel_interface) = endpoint.tunnel_interface else { + bail!("Unknown tunnel interface"); + }; + Ok(tunnel_interface) } - _ => None, + _ => bail!("Tunnel is not up"), } }