Skip to content

Commit 9c87146

Browse files
committed
updated to reflect proportion flooring
1 parent 505da80 commit 9c87146

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

test/rateLimiters/slidingWindowCounter.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ describe('Test TokenBucket Rate Limiter', () => {
104104
// tokens returned in processRequest is equal to the capacity
105105
// still available in the fixed window
106106

107-
const result = await limiter.processRequest(user4, timestamp + WINDOW_SIZE, 1);
107+
// rolling window proportion: .99999...
108+
// 1 + 10 * .9 = 10 (floored)
109+
const result = await limiter.processRequest(user4, timestamp + WINDOW_SIZE + 1, 1);
108110

109111
// should be allowed because formula is floored
110112
expect(result.success).toBe(true);

0 commit comments

Comments
 (0)