diff options
| author | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2024-02-06 14:59:01 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2024-02-08 15:53:35 +0100 |
| commit | eeca931f565dd7699e8d7f1209c65b1520834373 (patch) | |
| tree | bb014bec50c05cfe24b4c88f78ef2b28ed263d26 | |
| parent | 058a3e99dedcdccfe71b45b75ad060b8968cbc63 (diff) | |
| download | mullvadvpn-eeca931f565dd7699e8d7f1209c65b1520834373.tar.xz mullvadvpn-eeca931f565dd7699e8d7f1209c65b1520834373.zip | |
Remove `quicktest` dependency, replace usages with `proptest`.
| -rw-r--r-- | Cargo.lock | 23 | ||||
| -rw-r--r-- | talpid-core/Cargo.toml | 3 | ||||
| -rw-r--r-- | talpid-core/src/future_retry.rs | 17 |
3 files changed, 12 insertions, 31 deletions
diff --git a/Cargo.lock b/Cargo.lock index cb8c92e08b..5f37db970b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2783,26 +2783,6 @@ dependencies = [ ] [[package]] -name = "quickcheck" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" -dependencies = [ - "rand 0.8.5", -] - -[[package]] -name = "quickcheck_macros" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b22a693222d716a9587786f37ac3f6b4faedb5b80c23914e7303ff5a1d8016e9" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] name = "quote" version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3584,8 +3564,7 @@ dependencies = [ "once_cell", "parking_lot", "pfctl", - "quickcheck", - "quickcheck_macros", + "proptest", "rand 0.8.5", "resolv-conf", "subslice", diff --git a/talpid-core/Cargo.toml b/talpid-core/Cargo.toml index 4d2a54fc3f..1ec70876ff 100644 --- a/talpid-core/Cargo.toml +++ b/talpid-core/Cargo.toml @@ -94,6 +94,5 @@ features = [ tonic-build = { workspace = true, default-features = false, features = ["transport", "prost"] } [dev-dependencies] -quickcheck = { version = "1.0", default-features = false } -quickcheck_macros = "1.0" +proptest = "1.4" tokio = { workspace = true, features = [ "test-util" ] } diff --git a/talpid-core/src/future_retry.rs b/talpid-core/src/future_retry.rs index 197042e353..ee23de312f 100644 --- a/talpid-core/src/future_retry.rs +++ b/talpid-core/src/future_retry.rs @@ -153,6 +153,7 @@ fn apply_jitter(duration: Duration, jitter: f64) -> Duration { #[cfg(test)] mod test { use super::*; + use proptest::prelude::*; #[test] fn test_constant_interval() { @@ -220,13 +221,15 @@ mod test { assert_eq!(apply_jitter(second, 1.0), second); } - #[quickcheck_macros::quickcheck] - fn test_jitter(millis: u64, jitter: u64) { - let max_num = 2u64.checked_pow(f64::MANTISSA_DIGITS).unwrap(); - let jitter = (jitter % max_num) as f64 / (max_num as f64); - let unjittered_duration = Duration::from_millis(millis); - let jittered_duration = apply_jitter(unjittered_duration, jitter); - assert!(jittered_duration <= unjittered_duration); + proptest! { + #[test] + fn test_jitter(millis: u64, jitter: u64) { + let max_num = 2u64.checked_pow(f64::MANTISSA_DIGITS).unwrap(); + let jitter = (jitter % max_num) as f64 / (max_num as f64); + let unjittered_duration = Duration::from_millis(millis); + let jittered_duration = apply_jitter(unjittered_duration, jitter); + prop_assert!(jittered_duration <= unjittered_duration); + } } // NOTE: The test is disabled because the clock does not advance. |
