Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
lmuntaner committed Nov 7, 2024
1 parent 5150f4c commit 8943120
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/internet_identity/src/storage/registration_rates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<M: Memory> RegistrationRates<M> {
if dynamic_captcha_config().is_none() {
return;
};

let now = time();
self.reference_rate_data.push(&now).expect("out of memory");
self.current_rate_data.push(&now).expect("out of memory");
Expand Down Expand Up @@ -166,7 +166,7 @@ fn prune_data<M: Memory>(data: &mut MinHeap<Timestamp, M>, interval_ns: u64) ->
if timestamp > (now - interval_ns) {
break;
}

latest_pruned_interval = Some(now - timestamp);
data.pop();
}
Expand Down Expand Up @@ -283,22 +283,22 @@ mod test {

TIME.with_borrow_mut(|t| *t += Duration::from_secs(60).as_nanos() as u64);
registration_rates.new_registration();

// State of the current registrations heap: [10, 70]

TIME.with_borrow_mut(|t| *t += Duration::from_secs(10).as_nanos() as u64);
registration_rates.new_registration();

// State of the current registrations heap: [10, 70, 80]

TIME.with_borrow_mut(|t| *t += Duration::from_secs(20).as_nanos() as u64);
registration_rates.new_registration();

// State of the current registrations heap: [10, 70, 80, 100]

TIME.with_borrow_mut(|t| *t += Duration::from_secs(90).as_nanos() as u64);
registration_rates.new_registration();

// State of the current registrations heap: [100, 190]. 10, 70 and 80 got pruned.

assert!(!registration_rates
Expand Down Expand Up @@ -345,22 +345,22 @@ mod test {

TIME.with_borrow_mut(|t| *t += Duration::from_secs(60).as_nanos() as u64);
registration_rates.new_registration();

// State of the current registrations heap: [10, 70]

TIME.with_borrow_mut(|t| *t += Duration::from_secs(10).as_nanos() as u64);
registration_rates.new_registration();

// State of the current registrations heap: [10, 70, 80]

TIME.with_borrow_mut(|t| *t += Duration::from_secs(20).as_nanos() as u64);
registration_rates.new_registration();

// State of the current registrations heap: [10, 70, 80, 100]

TIME.with_borrow_mut(|t| *t += Duration::from_secs(90).as_nanos() as u64);
registration_rates.new_registration();

// State of the current registrations heap: [100, 190]. 10, 70 and 80 got pruned.

assert!(!registration_rates
Expand Down Expand Up @@ -613,7 +613,10 @@ mod test {
assert!(registration_rates.registration_rates().is_none());
}

fn setup(current_rate_sampling_interval_s: u64, reference_rate_sampling_interval_s: u64) -> RegistrationRates<VectorMemory> {
fn setup(
current_rate_sampling_interval_s: u64,
reference_rate_sampling_interval_s: u64,
) -> RegistrationRates<VectorMemory> {
reset_time();

// setup config
Expand Down

0 comments on commit 8943120

Please sign in to comment.