Skip to content

Commit

Permalink
Block event loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Ignacio Ubeira committed Nov 29, 2023
1 parent fc59111 commit 3164cad
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/forkTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ export function describeForkTest(name: string, forkNetwork: Network, blockNumber
// Delay between retries (only if the attempt fails)
afterEach(async function () {
if (this.currentTest?.state === undefined) {
const delay = 10000;
const delay = 5000;
const formattedMessage = chalk.keyword('yellow')(
`⚠️ Test '${this.currentTest?.title}' failed, retrying in ${delay}ms`
);
console.warn(formattedMessage);
const sleep = () => new Promise((r) => setTimeout(r, delay));
await sleep();

// Block event loop to ensure no requests are sent to the RPC.
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < 5000);
}
});
}
Expand Down

0 comments on commit 3164cad

Please sign in to comment.