Skip to content

Commit

Permalink
chore(synthetic-chain): Improve JS waitForBlock output (merge #196)
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 authored Nov 19, 2024
2 parents 8f24776 + 40e20bc commit e88a244
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/synthetic-chain/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agoric/synthetic-chain",
"version": "0.4.2",
"version": "0.4.3",
"description": "Utilities to build a chain and test proposals atop it",
"bin": "dist/cli/cli.js",
"main": "./dist/lib/index.js",
Expand Down
22 changes: 10 additions & 12 deletions packages/synthetic-chain/src/lib/commonUpgradeHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,20 @@ const waitForBootstrap = async (): Promise<number> => {
}
};

export const waitForBlock = async (times = 1) => {
console.log(times);
let time = 0;
while (time < times) {
const block1 = await waitForBootstrap();
export const waitForBlock = async (n = 1) => {
console.log(`waitForBlock waiting for ${n} new block(s)...`);
const h0 = await waitForBootstrap();
let lastHeight = h0;
for (let i = 0; i < n; i += 1) {
while (true) {
const block2 = await waitForBootstrap();

if (block1 !== block2) {
console.log('block produced');
await new Promise(r => setTimeout(r, 1000));
const currentHeight = await waitForBootstrap();
if (currentHeight !== lastHeight) {
console.log(`waitForBlock saw new height ${currentHeight}`);
lastHeight = currentHeight;
break;
}

await new Promise(r => setTimeout(r, 1000));
}
time += 1;
}
};

Expand Down

0 comments on commit e88a244

Please sign in to comment.