Skip to content

Commit

Permalink
chore: more timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
janniks committed Aug 1, 2024
1 parent 6366a6c commit 3380240
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,21 +276,20 @@ export async function waitForBurnBlockHeight(
burnBlockHeight: number,
interval: number = ENV.POLL_INTERVAL
): Promise<void> {
await timeout(100); // let the env catch up

let lastHeight = -1;
let lastHeightTime = Date.now();

while (true) {
const currentHeight = await getBurnBlockHeight();

if (currentHeight >= burnBlockHeight) break;
if (currentHeight >= burnBlockHeight) {
console.log(`block height ${currentHeight} (reached)`);
break;
}

if (currentHeight === lastHeight) {
if (Date.now() - lastHeightTime > ENV.BITCOIN_TX_TIMEOUT) {
throw new Error(
`Burn block height hasn't changed for ${ENV.BITCOIN_TX_TIMEOUT / 1000} seconds`
);
throw `Burn block height hasn't changed for ${ENV.BITCOIN_TX_TIMEOUT / 1000} seconds`;
}
} else {
lastHeight = currentHeight;
Expand Down
2 changes: 1 addition & 1 deletion src/tests/regtest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('regtest-env pox-4', () => {

if (ENV.SKIP_UNLOCK) return;
await waitForBurnBlockHeight(info.details.unlock_height + 2);
await timeout(200);
await timeout(400);
info = await client.getStatus();
expect(info.stacked).toBeFalsy();

Expand Down

0 comments on commit 3380240

Please sign in to comment.