Skip to content

Commit

Permalink
Enhance error message in waitForTermChange
Browse files Browse the repository at this point in the history
  • Loading branch information
foriequal0 committed Dec 10, 2019
1 parent ec0ef2b commit 06b3f97
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/src/helper/spawn.ts
Expand Up @@ -859,14 +859,16 @@ export default class CodeChain {
public async waitForTermChange(target: number, timeout?: number) {
const start = Date.now();
while (true) {
const termMetadata = await stake.getTermMetadata(this.sdk);
const termMetadata = (await stake.getTermMetadata(this.sdk))!;
if (termMetadata && termMetadata.currentTermId >= target) {
return termMetadata;
}
await wait(1000);
if (timeout) {
if (Date.now() - start > timeout * 1000) {
throw new Error(`Term didn't changed in ${timeout} s`);
throw new Error(
`Term didn't changed to ${target} in ${timeout} s. It is ${termMetadata.currentTermId} now`
);
}
}
}
Expand Down

0 comments on commit 06b3f97

Please sign in to comment.