protocol/contracts/utils/test/lib_rich_errors.ts
Xianny f0d7d10fe7
update abi-gen with new method interfaces (#2325)
* update abi-gen with new method interfaces

* wip: get all packages to build

* wip: get all packages to build

* Fix two contract wrapper calls

* Export necessary types part of the contract wrapper public interfaces

* Revive and fix wrapper_unit_tests

* Remove duplicate type

* Fix lib_exchange_rich_error_decoder tests

* Fix remaining test failures in contracts-* packages

* Prettier fixes

* remove transactionHelper

* lint and update changelogs

* Fix prettier

* Revert changes to reference docs

* Add back changelog already published and add revert changelog entry

* Add missing CHANGELOG entries

* Add missing comma

* Update mesh-rpc-client dep

* Update Mesh RPC logic in @0x/orderbook to v6.0.1-beta

* Align package versions
2019-11-14 11:22:29 -05:00

40 lines
1.4 KiB
TypeScript

import { blockchainTests, expect, hexRandom } from '@0x/contracts-test-utils';
import { coerceThrownErrorAsRevertError, StringRevertError } from '@0x/utils';
import { artifacts } from './artifacts';
import { TestLibRichErrorsContract } from './wrappers';
blockchainTests('LibRichErrors', env => {
let lib: TestLibRichErrorsContract;
before(async () => {
// Deploy SafeMath
lib = await TestLibRichErrorsContract.deployFrom0xArtifactAsync(
artifacts.TestLibRichErrors,
env.provider,
env.txDefaults,
{},
);
});
describe('_rrevert', () => {
it('should correctly revert the extra bytes', async () => {
const extraBytes = hexRandom(100);
try {
await lib.externalRRevert(extraBytes).callAsync();
} catch (err) {
const revertError = coerceThrownErrorAsRevertError(err);
return expect(revertError.encode()).to.eq(extraBytes);
}
return;
// TODO(xianny): NOT WORKING, v3 merge
// return expect.fail('Expected call to revert');
});
it('should correctly revert a StringRevertError', async () => {
const error = new StringRevertError('foo');
return expect(lib.externalRRevert(error.encode()).callAsync()).to.revertWith(error);
});
});
});