-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Reduce flakiness of the tests (#15860)
* chore: Reduce flakiness of the tests * wait for logs in batch tx tests * Increase timeout and retry couple of tests * Force every schema hash to be unique
- Loading branch information
Showing
8 changed files
with
53 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { performance } from 'perf_hooks' | ||
|
||
const MAX_WAIT = 5000 | ||
|
||
/** | ||
* Waits until provided callback stops throwing. | ||
* If it does not happen within MAX_WAIT, throws last thrown error | ||
* | ||
* Simplified version of testing-library's waitFor that works without DOM | ||
* https://testing-library.com/docs/dom-testing-library/api-async/#waitfor | ||
* @param cb | ||
*/ | ||
export async function waitFor(cb: () => void | Promise<void>) { | ||
const start = performance.now() | ||
let error: unknown = null | ||
|
||
while (performance.now() - start < MAX_WAIT) { | ||
try { | ||
await cb() | ||
return | ||
} catch (e) { | ||
error = e | ||
await delay(100) | ||
} | ||
} | ||
|
||
throw error | ||
} | ||
|
||
function delay(ms: number) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters