From eeca931f565dd7699e8d7f1209c65b1520834373 Mon Sep 17 00:00:00 2001 From: Sebastian Holmin Date: Tue, 6 Feb 2024 14:59:01 +0100 Subject: [PATCH] Remove `quicktest` dependency, replace usages with `proptest`. --- Cargo.lock | 23 +---------------------- talpid-core/Cargo.toml | 3 +-- talpid-core/src/future_retry.rs | 17 ++++++++++------- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cb8c92e08b0e..5f37db970b07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2782,26 +2782,6 @@ dependencies = [ "serde", ] -[[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" @@ -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 4d2a54fc3fb5..1ec70876ffcf 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 197042e353d7..ee23de312fcf 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.