From 470eab8352e8ec5b73744d16bb278180d6ec35aa Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Fri, 7 May 2021 09:10:40 -0700 Subject: [PATCH] Fix race condition in challenge test --- ts/test-both/challenge_test.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ts/test-both/challenge_test.ts b/ts/test-both/challenge_test.ts index 62b6700ce720..3a6de2719c47 100644 --- a/ts/test-both/challenge_test.ts +++ b/ts/test-both/challenge_test.ts @@ -24,6 +24,8 @@ type CreateHandlerOptions = { readonly onChallengeFailed?: (retryAfter?: number) => void; }; +const NEVER_RETRY = Date.now() + 365 * 24 * 3600 * 1000; + describe('ChallengeHandler', () => { const storage = new Map(); const messageStorage = new Map(); @@ -173,7 +175,7 @@ describe('ChallengeHandler', () => { it('should send challenge response', async () => { const handler = await createHandler({ challenge: true }); - const one = createMessage('1', { retryAfter: Date.now() + 100000 }); + const one = createMessage('1', { retryAfter: NEVER_RETRY }); messageStorage.set('1', one); await handler.register(one); @@ -348,7 +350,7 @@ describe('ChallengeHandler', () => { }); const one = createMessage('1', { - retryAfter: Date.now() + 1, + retryAfter: NEVER_RETRY, }); messageStorage.set('1', one); await handler.register(one); @@ -369,7 +371,7 @@ describe('ChallengeHandler', () => { }); const one = createMessage('1', { - retryAfter: Date.now() + 1, + retryAfter: NEVER_RETRY, }); messageStorage.set('1', one); await handler.register(one);