Skip to content

Commit

Permalink
fixup! fix: waitForBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Feb 3, 2025
1 parent 362ab41 commit d251503
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions multichain-testing/tools/e2e-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,27 @@ const makeBlockTool = ({ rpc, delay }) => {
}
};

let prevHeight = 0;
/**
* @param {number} [remaining] number of blocks to wait for
* @param {number} [advance] number of blocks to wait for
* @param {object} [info] add to logging
* @returns {Promise<void>}
*/
const waitForBlock = async (remaining = 1, info = {}) => {
const waitForBlock = async (advance = 1, info = {}) => {
await null;
while (remaining > 0) {
trace('waitForBlock', remaining, info);
while (true) {
const latestHeight = await waitForBootstrap(2000, {
...info,
last: prevHeight,
});

if (latestHeight > prevHeight) {
prevHeight = latestHeight;
break;
}

// Wait more for a new block
await delay(1000, info);
}
remaining -= 1;
const startHeight = await waitForBootstrap();
trace('waitForBlock starting at', startHeight, 'for', advance, info);
for (
let latestHeight = startHeight;
latestHeight < startHeight + advance;

) {
// Give some time for a new block
await delay(1000, { ...info, latestHeight });
latestHeight = await waitForBootstrap(2000, {
...info,
startHeight,
});
trace('waitForBlock', advance, info, 'saw', latestHeight);
}
};

Expand Down Expand Up @@ -199,7 +195,7 @@ export const provisionSmartWallet = async (
from: whale,
yes: true,
});
await blockTool.waitForBlock(1, { step: 'bank send' });
await blockTool.waitForBlock(1, { address, step: 'bank send' });
trace('sendFromWhale complete', address, denom, value);
};

Expand Down

0 comments on commit d251503

Please sign in to comment.