Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy lints in test workspace #5636

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 17 additions & 21 deletions test/test-manager/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub async fn connect_and_wait(mullvad_client: &mut ManagementServiceClient) -> R
mullvad_client
.connect_tunnel(())
.await
.map_err(|error| Error::DaemonError(format!("failed to begin connecting: {}", error)))?;
.map_err(|error| Error::Daemon(format!("failed to begin connecting: {}", error)))?;

let new_state = wait_for_tunnel_state(mullvad_client.clone(), |state| {
matches!(
Expand All @@ -211,7 +211,7 @@ pub async fn connect_and_wait(mullvad_client: &mut ManagementServiceClient) -> R
.await?;

if matches!(new_state, TunnelState::Error(..)) {
return Err(Error::DaemonError("daemon entered error state".to_string()));
return Err(Error::Daemon("daemon entered error state".to_string()));
}

log::info!("Connected");
Expand All @@ -227,7 +227,7 @@ pub async fn disconnect_and_wait(
mullvad_client
.disconnect_tunnel(())
.await
.map_err(|error| Error::DaemonError(format!("failed to begin disconnecting: {}", error)))?;
.map_err(|error| Error::Daemon(format!("failed to begin disconnecting: {}", error)))?;
wait_for_tunnel_state(mullvad_client.clone(), |state| {
matches!(state, TunnelState::Disconnected(_))
})
Expand All @@ -245,17 +245,15 @@ pub async fn wait_for_tunnel_state(
let events = rpc
.events_listen(())
.await
.map_err(|status| Error::DaemonError(format!("Failed to get event stream: {}", status)))?;
.map_err(|status| Error::Daemon(format!("Failed to get event stream: {}", status)))?;

let state = mullvad_types::states::TunnelState::try_from(
rpc.get_tunnel_state(())
.await
.map_err(|error| {
Error::DaemonError(format!("Failed to get tunnel state: {:?}", error))
})?
.map_err(|error| Error::Daemon(format!("Failed to get tunnel state: {:?}", error)))?
.into_inner(),
)
.map_err(|error| Error::DaemonError(format!("Invalid tunnel state: {:?}", error)))?;
.map_err(|error| Error::Daemon(format!("Invalid tunnel state: {:?}", error)))?;
if accept_state_fn(&state) {
return Ok(state);
}
Expand All @@ -272,7 +270,7 @@ pub async fn find_next_tunnel_state(
find_next_tunnel_state_inner(stream, accept_state_fn),
)
.await
.map_err(|_error| Error::DaemonError(String::from("Tunnel event listener timed out")))?
.map_err(|_error| Error::Daemon(String::from("Tunnel event listener timed out")))?
}

async fn find_next_tunnel_state_inner(
Expand All @@ -286,7 +284,7 @@ async fn find_next_tunnel_state_inner(
new_state,
) => {
let state = mullvad_types::states::TunnelState::try_from(new_state).map_err(
|error| Error::DaemonError(format!("Invalid tunnel state: {:?}", error)),
|error| Error::Daemon(format!("Invalid tunnel state: {:?}", error)),
)?;
if accept_state_fn(&state) {
return Ok(state);
Expand All @@ -295,12 +293,12 @@ async fn find_next_tunnel_state_inner(
_ => continue,
},
Some(Err(status)) => {
break Err(Error::DaemonError(format!(
break Err(Error::Daemon(format!(
"Failed to get next event: {}",
status
)))
}
None => break Err(Error::DaemonError(String::from("Lost daemon event stream"))),
None => break Err(Error::Daemon(String::from("Lost daemon event stream"))),
}
}
}
Expand All @@ -315,7 +313,7 @@ pub async fn geoip_lookup_with_retries(rpc: &ServiceClient) -> Result<AmIMullvad
let result = rpc
.geoip_lookup(TEST_CONFIG.mullvad_host.to_owned())
.await
.map_err(Error::GeoipError);
.map_err(Error::GeoipLookup);

attempt += 1;
if result.is_ok() || attempt >= MAX_ATTEMPTS {
Expand Down Expand Up @@ -371,19 +369,17 @@ pub async fn reset_relay_settings(

set_relay_settings(mullvad_client, relay_settings)
.await
.map_err(|error| {
Error::DaemonError(format!("Failed to reset relay settings: {}", error))
})?;
.map_err(|error| Error::Daemon(format!("Failed to reset relay settings: {}", error)))?;

mullvad_client
.set_bridge_state(types::BridgeState::from(bridge_state))
.await
.map_err(|error| Error::DaemonError(format!("Failed to reset bridge mode: {}", error)))?;
.map_err(|error| Error::Daemon(format!("Failed to reset bridge mode: {}", error)))?;

mullvad_client
.set_obfuscation_settings(types::ObfuscationSettings::from(obfuscation_settings))
.await
.map_err(|error| Error::DaemonError(format!("Failed to reset obfuscation: {}", error)))?;
.map_err(|error| Error::Daemon(format!("Failed to reset obfuscation: {}", error)))?;

Ok(())
}
Expand All @@ -397,7 +393,7 @@ pub async fn set_relay_settings(
mullvad_client
.set_relay_settings(new_settings)
.await
.map_err(|error| Error::DaemonError(format!("Failed to set relay settings: {}", error)))?;
.map_err(|error| Error::Daemon(format!("Failed to set relay settings: {}", error)))?;
Ok(())
}

Expand All @@ -410,7 +406,7 @@ pub async fn set_bridge_settings(
mullvad_client
.set_bridge_settings(new_settings)
.await
.map_err(|error| Error::DaemonError(format!("Failed to set bridge settings: {}", error)))?;
.map_err(|error| Error::Daemon(format!("Failed to set bridge settings: {}", error)))?;
Ok(())
}

Expand Down Expand Up @@ -484,7 +480,7 @@ where
let relay_list: RelayList = mullvad_client
.get_relay_locations(())
.await
.map_err(|error| Error::DaemonError(format!("Failed to obtain relay list: {}", error)))?
.map_err(|error| Error::Daemon(format!("Failed to obtain relay list: {}", error)))?
.into_inner()
.try_into()?;

Expand Down
2 changes: 1 addition & 1 deletion test/test-manager/src/tests/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub async fn test_upgrade_app(ctx: TestContext, rpc: ServiceClient) -> Result<()
}
})
.await
.map_err(|_error| Error::DaemonError(String::from("Failed to enter blocking error state")))?;
.map_err(|_error| Error::Daemon(String::from("Failed to enter blocking error state")))?;

//
// Begin monitoring outgoing traffic and pinging
Expand Down
4 changes: 2 additions & 2 deletions test/test-manager/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub enum Error {
PingTimeout,

#[error(display = "geoip lookup failed")]
GeoipError(test_rpc::Error),
GeoipLookup(test_rpc::Error),

#[error(display = "Found running daemon unexpectedly")]
DaemonRunning,
Expand All @@ -58,7 +58,7 @@ pub enum Error {
DaemonNotRunning,

#[error(display = "The daemon returned an error: {}", _0)]
DaemonError(String),
Daemon(String),

#[error(display = "Failed to parse gRPC response")]
InvalidGrpcResponse(#[error(source)] types::FromProtobufTypeError),
Expand Down
2 changes: 1 addition & 1 deletion test/test-manager/src/vm/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub use macos as platform;

// Import shared constants and functions
pub use platform::{
setup_test_network, CUSTOM_TUN_GATEWAY, CUSTOM_TUN_INTERFACE_NAME, CUSTOM_TUN_LOCAL_PRIVKEY,
CUSTOM_TUN_GATEWAY, CUSTOM_TUN_INTERFACE_NAME, CUSTOM_TUN_LOCAL_PRIVKEY,
CUSTOM_TUN_LOCAL_TUN_ADDR, CUSTOM_TUN_REMOTE_PUBKEY, CUSTOM_TUN_REMOTE_REAL_ADDR,
CUSTOM_TUN_REMOTE_REAL_PORT, CUSTOM_TUN_REMOTE_TUN_ADDR, DUMMY_LAN_INTERFACE_IP,
NON_TUN_GATEWAY,
Expand Down
Loading