forked from EduCraft/curriculum-project-hub
feat: add deployable alpha silo
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { SiloFixedWindowRateLimiter } from "../../src/deployment/siloRateLimit.js";
|
||||
|
||||
describe("Silo fixed-window rate limiter", () => {
|
||||
it("returns an explicit retry interval and resets at the next window", () => {
|
||||
const limiter = new SiloFixedWindowRateLimiter(2, 60_000, 1_000);
|
||||
expect(limiter.consume(1_000)).toEqual({ allowed: true });
|
||||
expect(limiter.consume(2_000)).toEqual({ allowed: true });
|
||||
expect(limiter.consume(3_000)).toEqual({ allowed: false, retryAfterSeconds: 58 });
|
||||
expect(limiter.consume(61_000)).toEqual({ allowed: true });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user