()
| 275 | |
| 276 | #[test] |
| 277 | fn test_delay_for_attempt_exponential() { |
| 278 | let config = RetryConfig { |
| 279 | base_delay_ms: 1000, |
| 280 | max_delay_ms: 60_000, |
| 281 | ..Default::default() |
| 282 | }; |
| 283 | |
| 284 | // Attempt 0: ~1000ms (with jitter) |
| 285 | let d0 = config.delay_for_attempt(0); |
| 286 | assert!(d0.as_millis() >= 750 && d0.as_millis() <= 1250); |
| 287 | |
| 288 | // Attempt 1: ~2000ms (with jitter) |
| 289 | let d1 = config.delay_for_attempt(1); |
| 290 | assert!(d1.as_millis() >= 1500 && d1.as_millis() <= 2500); |
| 291 | |
| 292 | // Attempt 2: ~4000ms (with jitter) |
| 293 | let d2 = config.delay_for_attempt(2); |
| 294 | assert!(d2.as_millis() >= 3000 && d2.as_millis() <= 5000); |
| 295 | } |
| 296 | |
| 297 | #[test] |
| 298 | fn test_delay_capped_at_max() { |
nothing calls this directly
no test coverage detected