()
| 130 | |
| 131 | #[test] |
| 132 | fn refills_over_time() { |
| 133 | let config = RateLimitConfig { |
| 134 | rate_per_sec: 1000.0, // Fast refill for test. |
| 135 | burst: 5, |
| 136 | }; |
| 137 | let mut limiter = SyncRateLimiter::new(&config); |
| 138 | |
| 139 | // Drain all tokens. |
| 140 | for _ in 0..5 { |
| 141 | limiter.try_acquire().ok(); |
| 142 | } |
| 143 | assert!(limiter.try_acquire().is_err()); |
| 144 | |
| 145 | // Wait for refill (at 1000/s, 10ms = ~10 tokens, capped at burst=5). |
| 146 | thread::sleep(Duration::from_millis(10)); |
| 147 | |
| 148 | // Should have tokens again. |
| 149 | assert!(limiter.try_acquire().is_ok()); |
| 150 | } |
| 151 | |
| 152 | #[test] |
| 153 | fn retry_after_is_reasonable() { |
nothing calls this directly
no test coverage detected