Skip to content

Commit 9c035ee

Browse files
committed
Merge branch 'mtu-detection-tests-nft' into main
2 parents cd5f335 + 301a123 commit 9c035ee

File tree

12 files changed

+367
-143
lines changed

12 files changed

+367
-143
lines changed

test/Cargo.lock

+72-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/Cargo.toml

+12-8
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ rust-version = "1.75.0"
77

88
[workspace]
99
resolver = "2"
10-
members = [
11-
"test-manager",
12-
"test-runner",
13-
"test-rpc",
14-
"socks-server",
15-
]
10+
members = ["test-manager", "test-runner", "test-rpc", "socks-server"]
1611

1712
[workspace.lints.rust]
1813
rust_2018_idioms = "deny"
@@ -22,7 +17,15 @@ unused_async = "deny"
2217

2318
[workspace.dependencies]
2419
futures = "0.3"
25-
tokio = { version = "1.8", features = ["macros", "rt", "process", "time", "fs", "io-util", "rt-multi-thread"] }
20+
tokio = { version = "1.8", features = [
21+
"macros",
22+
"rt",
23+
"process",
24+
"time",
25+
"fs",
26+
"io-util",
27+
"rt-multi-thread",
28+
] }
2629
tokio-serial = "5.4.1"
2730
# Serde and related crates
2831
serde = "1.0"
@@ -46,8 +49,9 @@ shadowsocks-service = { version = "1.16" }
4649

4750
windows-sys = "0.48.0"
4851

49-
chrono = { version = "0.4.26", default-features = false}
52+
chrono = { version = "0.4.26", default-features = false }
5053
clap = { version = "4.2.7", features = ["cargo", "derive"] }
5154
once_cell = "1.16.0"
5255
bytes = "1.3.0"
5356
async-trait = "0.1.58"
57+
surge-ping = "0.8"

test/test-manager/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ async-tempfile = "0.2"
3232
async-trait = { workspace = true }
3333
uuid = "1.3"
3434
dirs = "5.0.1"
35+
scopeguard = "1.2"
3536

3637
serde = { workspace = true }
3738
serde_json = { workspace = true }

test/test-manager/src/tests/helpers.rs

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{config::TEST_CONFIG, Error, PING_TIMEOUT, WAIT_FOR_TUNNEL_STATE_TIMEOUT};
1+
use super::{config::TEST_CONFIG, Error, WAIT_FOR_TUNNEL_STATE_TIMEOUT};
22
use crate::network_monitor::{
33
self, start_packet_monitor, MonitorOptions, MonitorUnexpectedlyStopped, PacketMonitor,
44
};
@@ -21,7 +21,6 @@ use std::{
2121
};
2222
use talpid_types::net::wireguard::{PeerConfig, PrivateKey, TunnelConfig};
2323
use test_rpc::{package::Package, AmIMullvad, ServiceClient};
24-
use tokio::time::timeout;
2524

2625
#[macro_export]
2726
macro_rules! assert_tunnel_state {
@@ -182,9 +181,21 @@ pub async fn ping_with_timeout(
182181
dest: IpAddr,
183182
interface: Option<String>,
184183
) -> Result<(), Error> {
185-
timeout(PING_TIMEOUT, rpc.send_ping(interface, dest))
184+
const DEFAULT_PING_SIZE: usize = 64;
185+
186+
rpc.send_ping(dest, interface, DEFAULT_PING_SIZE)
187+
.await
188+
.map_err(Error::Rpc)
189+
}
190+
191+
pub async fn ping_sized_with_timeout(
192+
rpc: &ServiceClient,
193+
dest: IpAddr,
194+
interface: Option<String>,
195+
size: usize,
196+
) -> Result<(), Error> {
197+
rpc.send_ping(dest, interface, size)
186198
.await
187-
.map_err(|_| Error::PingTimeout)?
188199
.map_err(Error::Rpc)
189200
}
190201

@@ -506,8 +517,9 @@ impl Pinger {
506517
log::debug!("Monitoring outgoing traffic");
507518
let monitor = start_packet_monitor(
508519
move |packet| {
509-
// NOTE: Many packets will likely be observed for API traffic. Rather than filtering all
510-
// of those specifically, simply fail if our probes are observed.
520+
// NOTE: Many packets will likely be observed for API traffic. Rather than filtering
521+
// all of those specifically, simply fail if our probes are
522+
// observed.
511523
packet.source.ip() == guest_ip
512524
&& packet.destination.ip() == builder.destination.ip()
513525
},

test/test-manager/src/tests/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use futures::future::BoxFuture;
2121
use mullvad_management_interface::MullvadProxyClient;
2222
use std::time::Duration;
2323

24-
const PING_TIMEOUT: Duration = Duration::from_secs(3);
2524
const WAIT_FOR_TUNNEL_STATE_TIMEOUT: Duration = Duration::from_secs(40);
2625

2726
#[derive(Clone)]
@@ -42,9 +41,6 @@ pub enum Error {
4241
#[error("RPC call failed")]
4342
Rpc(#[from] test_rpc::Error),
4443

45-
#[error("Timeout waiting for ping")]
46-
PingTimeout,
47-
4844
#[error("geoip lookup failed")]
4945
GeoipLookup(test_rpc::Error),
5046

0 commit comments

Comments
 (0)