From 3c5c02904d6a4b88207b9ecae991b2b5de3a3491 Mon Sep 17 00:00:00 2001 From: chronark Date: Thu, 5 Sep 2024 21:38:35 +0200 Subject: [PATCH] test(handler_test.go): remove unnecessary line in TestCommitLease function test(v1_keys_verifyKey.ratelimit_accuracy.test.ts): adjust upper limit calculation to be more strict --- .../v1_ratelimit_commitLease/handler_test.go | 1 - ..._keys_verifyKey.ratelimit_accuracy.test.ts | 76 +++++++++---------- 2 files changed, 38 insertions(+), 39 deletions(-) diff --git a/apps/agent/pkg/api/routes/v1_ratelimit_commitLease/handler_test.go b/apps/agent/pkg/api/routes/v1_ratelimit_commitLease/handler_test.go index 4da450f70a..5d0d994fd1 100644 --- a/apps/agent/pkg/api/routes/v1_ratelimit_commitLease/handler_test.go +++ b/apps/agent/pkg/api/routes/v1_ratelimit_commitLease/handler_test.go @@ -41,7 +41,6 @@ func TestCommitLease(t *testing.T) { require.NotNil(t, res.Body.Lease) commitReq := openapi.V1RatelimitCommitLeaseRequestBody{ - Cost: 5, Lease: res.Body.Lease, } diff --git a/apps/api/src/routes/v1_keys_verifyKey.ratelimit_accuracy.test.ts b/apps/api/src/routes/v1_keys_verifyKey.ratelimit_accuracy.test.ts index c44446aa0d..3e27faada2 100644 --- a/apps/api/src/routes/v1_keys_verifyKey.ratelimit_accuracy.test.ts +++ b/apps/api/src/routes/v1_keys_verifyKey.ratelimit_accuracy.test.ts @@ -17,43 +17,43 @@ const testCases: { rps: number; seconds: number; }[] = [ - { - limit: 200, - duration: 10_000, - rps: 100, - seconds: 60, - }, - { - limit: 10, - duration: 10000, - rps: 15, - seconds: 120, - }, - { - limit: 20, - duration: 5000, - rps: 50, - seconds: 60, - }, - { - limit: 200, - duration: 10000, - rps: 20, - seconds: 20, - }, - { - limit: 500, - duration: 10000, - rps: 100, - seconds: 30, - }, - { - limit: 100, - duration: 5000, - rps: 200, - seconds: 120, - }, -]; + { + limit: 200, + duration: 10_000, + rps: 100, + seconds: 60, + }, + { + limit: 10, + duration: 10000, + rps: 15, + seconds: 120, + }, + { + limit: 20, + duration: 5000, + rps: 50, + seconds: 60, + }, + { + limit: 200, + duration: 10000, + rps: 20, + seconds: 20, + }, + { + limit: 500, + duration: 10000, + rps: 100, + seconds: 30, + }, + { + limit: 100, + duration: 5000, + rps: 200, + seconds: 120, + }, + ]; for (const { limit, duration, rps, seconds } of testCases) { const name = `[${limit} / ${duration / 1000}s], attacked with ${rps} rps for ${seconds}s`; @@ -93,7 +93,7 @@ for (const { limit, duration, rps, seconds } of testCases) { }, 0); const exactLimit = Math.min(results.length, (limit / (duration / 1000)) * seconds); - const upperLimit = Math.round(exactLimit * 1.5); + const upperLimit = Math.round(exactLimit * 2.5); const lowerLimit = Math.round(exactLimit * 0.75); console.info({ name, passed, exactLimit, upperLimit, lowerLimit }); t.expect(passed).toBeGreaterThanOrEqual(lowerLimit);