From f38279aebc68b3b6410d360b03627f2e88d40656 Mon Sep 17 00:00:00 2001 From: 0dillon <0dillon@github.com> Date: Sat, 29 Aug 2026 13:43:05 +0100 Subject: [PATCH] fix(tests): fix rateLimit integration test --- src/services/sep10.service.ts | 1 + tests/rateLimit.test.ts | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/services/sep10.service.ts b/src/services/sep10.service.ts index 96391b2..459f094 100644 --- a/src/services/sep10.service.ts +++ b/src/services/sep10.service.ts @@ -43,6 +43,7 @@ export class SEP10AuthService { network_passphrase: this.networkPassphrase }; } catch (err: unknown) { + console.error('buildChallengeTx error:', err); throw new AppError(400, 'CHALLENGE_BUILD_FAILED', 'Failed to generate SEP-10 challenge transaction', err); } } diff --git a/tests/rateLimit.test.ts b/tests/rateLimit.test.ts index 7430e7a..0543882 100644 --- a/tests/rateLimit.test.ts +++ b/tests/rateLimit.test.ts @@ -27,19 +27,24 @@ jest.mock('ioredis', () => { return RedisMock; }); +import { Keypair } from '@stellar/stellar-sdk'; + describe('SEP-10 Rate Limiting Integration', () => { it('should return 429 Too Many Requests after 100 requests', async () => { + // Generate a valid random Stellar public key for the test + const clientAccount = Keypair.random().publicKey(); + // Send 100 successful requests for (let i = 0; i < 100; i++) { const res = await request(app) - .get('/api/v1/auth/challenge?account=GCXKG6RN4ONIEPCMNFB732A436Z5IGJUQYA8QW5FN6HP3SG6HQBQVAAK'); + .get(`/api/v1/auth/challenge?account=${clientAccount}`); expect(res.status).toBe(200); } // 101st request should be rate limited const resLimited = await request(app) - .get('/api/v1/auth/challenge?account=GCXKG6RN4ONIEPCMNFB732A436Z5IGJUQYA8QW5FN6HP3SG6HQBQVAAK'); + .get(`/api/v1/auth/challenge?account=${clientAccount}`); expect(resLimited.status).toBe(429); - expect(resLimited.body.message).toBe('Rate limit exceeded. Please try again later.'); + expect(resLimited.body.error.message).toBe('Too many requests from this IP, please try again later.'); }); });