Skip to content

Commit

Permalink
Increase timeouts for tip height waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi committed Oct 24, 2021
1 parent ea100fb commit 9e6fc82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
19 changes: 9 additions & 10 deletions integration_tests/features/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const {
consoleLogBalance,
consoleLogTransactionDetails,
withTimeout,
waitForIterate,
} = require("../../helpers/util");
const { ConnectivityStatus, PaymentType } = require("../../helpers/types");
const TransactionBuilder = require("../../helpers/transactionBuilder");
Expand Down Expand Up @@ -830,14 +831,15 @@ When(/I stop node (.*)/, async function (name) {

Then(
/node (.*) is at height (\d+)/,
{ timeout: 120 * 1000 },
{ timeout: 210 * 1000 },
async function (name, height) {
const client = this.getClient(name);
await waitForPredicate(
async () => (await client.getTipHeight()) === height,
115 * 1000
const currentHeight = await waitForIterate(
() => client.getTipHeight(),
height,
1000,
200
);
const currentHeight = await client.getTipHeight();
console.log(
`Node ${name} is at tip: ${currentHeight} (should be`,
height,
Expand Down Expand Up @@ -900,10 +902,7 @@ Then(
async function (height) {
let tipHash = null;
await this.forEachClientAsync(async (client, name) => {
await waitForPredicate(
async () => (await client.getTipHeight()) === height,
115 * 1000
);
await waitForIterate(() => client.getTipHeight(), height, 200 * 1000);
const currTip = await client.getTipHeader();
console.log(
`${client.name} is at tip ${currTip.height} (${currTip.hash.toString(
Expand Down Expand Up @@ -994,7 +993,7 @@ Then(
async function (node) {
const client = this.getClient(node);
await waitForPredicate(
async () => (await client.initial_sync_achieved()) === true,
async () => await client.initial_sync_achieved(),
20 * 60 * 1000,
1000
);
Expand Down
7 changes: 4 additions & 3 deletions integration_tests/helpers/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,17 @@ async function waitFor(

async function waitForIterate(testFn, toBe, sleepMs, maxIterations = 500) {
let count = 0;
let val = testFn();
while (!(val === toBe)) {
val = testFn();
let val = await Promise.resolve(testFn());
while (val !== toBe) {
val = await Promise.resolve(testFn());
if (count >= maxIterations) {
break;
}
count++;
await sleep(sleepMs);
process.stdout.write(".");
}
return val;
}

async function waitForPredicate(predicate, timeOut, sleepMs = 500) {
Expand Down

0 comments on commit 9e6fc82

Please sign in to comment.