Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
@0x/contracts-utils: Fix failing tests due to RevertError behavio…
Browse files Browse the repository at this point in the history
…r changes.
  • Loading branch information
dorothy-zbornak committed Aug 30, 2019
1 parent 8c86806 commit 2ab67c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion contracts/utils/test/authorizable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('Authorizable', () => {
constants.AWAIT_TRANSACTION_MINED_MS,
);
const index = new BigNumber(1);
const expectedError = new AuthorizableRevertErrors.IndexOutOfBoundsError(index, constants.ZERO_AMOUNT);
const expectedError = new AuthorizableRevertErrors.IndexOutOfBoundsError(index, index);
const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
from: owner,
});
Expand Down
31 changes: 13 additions & 18 deletions contracts/utils/test/lib_rich_errors.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
import { chaiSetup, constants, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { StringRevertError } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import { blockchainTests, expect, hexRandom } from '@0x/contracts-test-utils';
import { coerceThrownErrorAsRevertError, StringRevertError } from '@0x/utils';

import { artifacts, TestLibRichErrorsContract } from '../src';

chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);

describe('LibRichErrors', () => {
blockchainTests('LibRichErrors', env => {
let lib: TestLibRichErrorsContract;

before(async () => {
await blockchainLifecycle.startAsync();
// Deploy SafeMath
lib = await TestLibRichErrorsContract.deployFrom0xArtifactAsync(
artifacts.TestLibRichErrors,
provider,
txDefaults,
env.provider,
env.txDefaults,
{},
);
});

after(async () => {
await blockchainLifecycle.revertAsync();
});

describe('_rrevert', () => {
it('should correctly revert the extra bytes', async () => {
return expect(lib.externalRRevert.callAsync(constants.NULL_BYTES)).to.revertWith(constants.NULL_BYTES);
const extraBytes = hexRandom(100);
try {
await lib.externalRRevert.callAsync(extraBytes);
} catch (err) {
const revertError = coerceThrownErrorAsRevertError(err);
return expect(revertError.encode()).to.eq(extraBytes);
}
return expect.fail('Expected call to revert');
});

it('should correctly revert a StringRevertError', async () => {
Expand Down

0 comments on commit 2ab67c7

Please sign in to comment.