From 209ea18f6393fb90710dc869e4f4a310e192a0b0 Mon Sep 17 00:00:00 2001 From: Amin Moghaddam Date: Thu, 12 Jun 2025 16:52:55 -0700 Subject: [PATCH] feat(entropy-tester): set timeout for total testLatency function --- apps/entropy-tester/package.json | 2 +- apps/entropy-tester/src/index.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/entropy-tester/package.json b/apps/entropy-tester/package.json index 4d687a410f..5b46ca3454 100644 --- a/apps/entropy-tester/package.json +++ b/apps/entropy-tester/package.json @@ -1,6 +1,6 @@ { "name": "@pythnetwork/entropy-tester", - "version": "1.0.1", + "version": "1.0.2", "description": "Utility to test entropy provider callbacks", "type": "module", "main": "dist/index.js", diff --git a/apps/entropy-tester/src/index.ts b/apps/entropy-tester/src/index.ts index a08972095f..815812c8f1 100644 --- a/apps/entropy-tester/src/index.ts +++ b/apps/entropy-tester/src/index.ts @@ -181,7 +181,18 @@ export const main = function () { // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition while (true) { try { - await testLatency(contract, privateKey, child); + await Promise.race([ + testLatency(contract, privateKey, child), + new Promise((_, reject) => + setTimeout(() => { + reject( + new Error( + "Timeout: 120s passed but testLatency function was not resolved", + ), + ); + }, 120_000), + ), + ]); } catch (error) { child.error(error, "Error testing latency"); }