Skip to content

Commit 007689e

Browse files
committed
test(Task): hardening ratelimit spec
1 parent b68132e commit 007689e

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

‎src/core/task/__tests__/Task.spec.ts‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -735,15 +735,10 @@ describe("Cline", () => {
735735
const iterator = cline.attemptApiRequest(0)
736736
await iterator.next()
737737

738-
// The retry should have used the rate limit window.
739-
// recordRequest() was called during attemptApiRequest, so the
740-
// clock has a timestamp, and rateLimitSeconds=10 means the
741-
// backoff should account for the rate limit window (10s) being
742-
// larger than the base exponential delay (3s).
743-
const retryMessages = saySpy.mock.calls.filter((call) => call[0] === "api_req_retry_delayed")
744-
expect(retryMessages.length).toBeGreaterThan(0)
745-
746-
// Verify the clock was used (it should have a recorded timestamp)
738+
// rateLimitSeconds=10 > exponentialDelay=ceil(3*2^0)=3, so
739+
// finalDelay=10 and the countdown loop fires delay(1000) ten times.
740+
expect(mockDelay).toHaveBeenCalledWith(1000)
741+
expect(mockDelay).toHaveBeenCalledTimes(10)
747742
expect(clock.getLastRequestTime()).toBeDefined()
748743
})
749744

0 commit comments

Comments
 (0)