From 2694742003e87f0692022d411a2c673ff854f0fd Mon Sep 17 00:00:00 2001 From: fmacleal Date: Fri, 12 Jul 2024 16:13:45 +0200 Subject: [PATCH] Adding the waitTime and maxAttempts configurable with env variables --- .env-example | 10 ++++++++++ lib/rsk-utils-legacy.js | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.env-example b/.env-example index fd4e7b5e..0ab76096 100644 --- a/.env-example +++ b/.env-example @@ -1,3 +1,13 @@ INCLUDE_CASES=00_00_01-sync.js,01_01_01-pre_orchid_2wp.js RUN_EACH_TEST_FILE_THESE_TIMES=1 RUN_ALL_TESTS_THESE_TIMES=1 + +# Sets the maximum wait time in seconds for a block confirmation before timing out +# This parameter helps in defining how long to wait for a block of within a test to execute before considering the test as failed due to timeout. +# Leave empty to use the default value set within the test framework. +WAIT_TIME_DEFAULT= + +# Sets the maximum number of attempts for a test. +# This is used to specify how many times a test should be retried upon failure before being marked as failed. +# Leave empty to use the default value set within the test framework. +MAX_ATTEMPTS_DEFAULT= diff --git a/lib/rsk-utils-legacy.js b/lib/rsk-utils-legacy.js index 9ef75469..e46a1e85 100644 --- a/lib/rsk-utils-legacy.js +++ b/lib/rsk-utils-legacy.js @@ -2,6 +2,8 @@ const expect = require('chai').expect; const btcClientProvider = require('./btc-client-provider'); const { sequentialPromise, wait, interval } = require('./utils'); const { getBridgeAbi, getLatestActiveForkName } = require('./precompiled-abi-forks-util'); +const WAIT_TIME_DEFAULT = process.env.WAIT_TIME_DEFAULT || 600 +const MAX_ATTEMPTS_DEFAULT = process.env.MAX_ATTEMPTS_DEFAULT || 1000 var getMaxBlockNumber = (rskClients) => { var maxBlockNumber; @@ -26,7 +28,7 @@ var waitForSync = (rskClients) => { }); }; -var waitForBlock = (rskClient, blockNumber, waitTime = 600, maxAttempts = 1000) => { +var waitForBlock = (rskClient, blockNumber, waitTime = WAIT_TIME_DEFAULT, maxAttempts = MAX_ATTEMPTS_DEFAULT) => { return new Promise((resolve, reject) => { var clearPoll; var attempts = 0;