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 });
  });
});
