Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lmuntaner committed Nov 5, 2024
1 parent 1075b4a commit 279359f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/internet_identity/src/storage/registration_rates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,26 +319,24 @@ mod test {
assert_eq!(
registration_rates.registration_rates().unwrap(),
NormalizedRegistrationRates {
current_rate_per_second: 100.0,
reference_rate_per_second: 100.0,
captcha_threshold_rate: 120.0,
current_rate_per_second: 1.0,
reference_rate_per_second: 0.1,
captcha_threshold_rate: 0.12,
}
);

// move time forward by reference rate time interval
TIME.with_borrow_mut(|t| *t += Duration::from_secs(1000).as_nanos() as u64);

// Adding a new data point prunes everything except the one data point added now
// -> there are at least 2 data points required to calculate a rate
// -> rates are 0.0
registration_rates.new_registration();

assert_eq!(
registration_rates.registration_rates().unwrap(),
NormalizedRegistrationRates {
current_rate_per_second: 0.0,
reference_rate_per_second: 0.0,
captcha_threshold_rate: 0.0,
current_rate_per_second: 0.01,
reference_rate_per_second: 0.001,
captcha_threshold_rate: 0.0012,
}
);
}
Expand Down

0 comments on commit 279359f

Please sign in to comment.