RevertError: Decode Parity revert errors

This commit is contained in:
Jacob Evans
2019-11-15 19:07:28 +10:00
parent 58276cefce
commit 42dc112a13
3 changed files with 45 additions and 2 deletions

View File

@@ -1,7 +1,13 @@
import * as chai from 'chai';
import * as _ from 'lodash';
import { AnyRevertError, RawRevertError, RevertError, StringRevertError } from '../src/revert_error';
import {
AnyRevertError,
getThrownErrorRevertErrorBytes,
RawRevertError,
RevertError,
StringRevertError,
} from '../src/revert_error';
import { chaiSetup } from './utils/chai_setup';
@@ -154,6 +160,14 @@ describe('RevertError', () => {
expect(decode).to.throw();
});
});
describe('getThrownErrorRevertErrorBytes', () => {
it('should decode Parity revert errors', () => {
const revertAbi = '0x1234';
const parityError = { code: 1234, message: 'VM execution error.', data: `Reverted ${revertAbi}`, name: '' };
const revertError = getThrownErrorRevertErrorBytes(parityError);
expect(revertError).to.be.eq(revertAbi);
});
});
describe('encoding', () => {
const message = 'foobar';
it('should be able to encode', () => {