Skip to content

Commit

Permalink
Merge branch 'mtu-detection-linux'
Browse files Browse the repository at this point in the history
  • Loading branch information
dlon committed Feb 8, 2024
2 parents bc51bf6 + eeca931 commit 0afb7cc
Show file tree
Hide file tree
Showing 12 changed files with 441 additions and 89 deletions.
183 changes: 159 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions talpid-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ] }
17 changes: 10 additions & 7 deletions talpid-core/src/future_retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 0afb7cc

Please sign in to comment.