Support IO token bucket capacity > refill rate

This commit is contained in:
Calvin Montgomery 2018-11-15 23:04:03 -08:00
parent 8456b6a125
commit 4c9e85b293
4 changed files with 21 additions and 7 deletions

View file

@ -54,5 +54,13 @@ describe('TokenBucket', () => {
assert(!bucket.throttle());
assert.strictEqual(bucket.count, 0);
});
it('handles infinite refill rate and capacity', () => {
bucket = new TokenBucket(Infinity, Infinity);
for (let i = 0; i < 100; i++) {
assert(!bucket.throttle(), 'should not throttle');
}
});
});
});