in amazon-qldb-driver-core/src/retry.rs [136:159]
fn exponential_backoff_with_jitter_seq() {
let ExponentialBackoffJitterTransactionRetryPolicy {
base,
cap,
max_attempts,
} = ExponentialBackoffJitterTransactionRetryPolicy::default();
let mut seq = vec![0..10, 0..100, 0..1000, 0..5000]; // not super tight
seq.reverse();
for attempt_number in 1..=max_attempts {
let sleep = exponential_backoff_with_jitter(base, cap, attempt_number);
let expected = seq.pop().unwrap();
assert!(
expected.contains(&(sleep as u32)),
"on attempt {} we should be sleeping in the range {:?} but we calculated {}",
attempt_number,
expected,
sleep
);
}
assert!(seq.is_empty());
}