Skip to content

Commit

Permalink
Fixed assertion on EOS errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
thekevinbrown committed Apr 16, 2019
1 parent be3a69c commit ba7702d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,25 @@ export const assertRowCount = async (

export const assertEOSError = async (
operation: Promise<any>,
eosErrorText: string,
eosErrorName: string,
description: string
) => {
try {
await operation;
} catch (error) {
const expectedError = error.search(eosErrorText) >= 0;
assert(expectedError, `Expected ${description}, got '${error}' instead`);
return;
if (error.json && error.json.error && error.json.error.name) {
assert(
error.json.error.name === eosErrorName,
`Expected ${eosErrorName}, got ${error.json.error.name} instead.`
);
return;
} else {
assert.fail(
`Expected EOS error ${eosErrorName}, but got ${JSON.stringify(error, null, 4)} instead.`
);
}
}

assert.fail(`Expected ${description} but operation completed successfully.`);
};

Expand Down

0 comments on commit ba7702d

Please sign in to comment.