From ba7702d5f6d242d289503816f39edf0f0bc991a7 Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Tue, 16 Apr 2019 15:44:06 +1000 Subject: [PATCH] Fixed assertion on EOS errors. --- src/utils.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 1837fdf..ed3910e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -47,16 +47,25 @@ export const assertRowCount = async ( export const assertEOSError = async ( operation: Promise, - 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.`); };