Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(synthetic-chain): Improve JS waitForBlock output #196

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading