diff --git a/src/index.spec.ts b/src/index.spec.ts index 0272c69..e31e4bc 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -27,15 +27,17 @@ describe('integration test', () => { const rateLimiter = getLeakyBucketRateLimiter({ redis, bucketTypes: { - // 6 invocations a second + // Drain at 3 invocations a second bucket: { capacity: 6, drainCount: 3, - drainInterval: 2000, + drainInterval: 1000, }, }, }); + let highestN = 0; + const task: Task = async (payload: any) => { if (payload.n > highestN) { highestN = payload.n; @@ -51,8 +53,6 @@ describe('integration test', () => { pollInterval: 20, // need a smaller poll interval }); - let highestN = 0; - // if i add 7 jobs, 6 should be run after 100ms, but the 7th shouldnt be run until after 1.1 seconds await Promise.all( [...Array(7)].map((_, n) => {