Updated the asset-proxy tests to use RichErrors
This commit is contained in:
parent
f4551dd1e5
commit
b7bac3abf6
@ -8,7 +8,7 @@ import {
|
|||||||
} from '@0x/contracts-test-utils';
|
} from '@0x/contracts-test-utils';
|
||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||||
import { RevertReason } from '@0x/types';
|
import { RevertReason } from '@0x/types';
|
||||||
import { BigNumber } from '@0x/utils';
|
import { BigNumber, OwnableRevertErrors } from '@0x/utils';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
@ -47,10 +47,11 @@ describe('Authorizable', () => {
|
|||||||
});
|
});
|
||||||
describe('addAuthorizedAddress', () => {
|
describe('addAuthorizedAddress', () => {
|
||||||
it('should throw if not called by owner', async () => {
|
it('should throw if not called by owner', async () => {
|
||||||
return expectTransactionFailedAsync(
|
const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner);
|
||||||
authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }),
|
const tx = authorizable.addAuthorizedAddress.sendTransactionAsync(
|
||||||
RevertReason.OnlyContractOwner,
|
notOwner, { from: notOwner }
|
||||||
);
|
);
|
||||||
|
expect(tx).to.revertWith(expectedError);
|
||||||
});
|
});
|
||||||
it('should allow owner to add an authorized address', async () => {
|
it('should allow owner to add an authorized address', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
||||||
@ -81,12 +82,11 @@ describe('Authorizable', () => {
|
|||||||
{ from: owner },
|
{ from: owner },
|
||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
);
|
);
|
||||||
return expectTransactionFailedAsync(
|
const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner);
|
||||||
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
|
const tx = authorizable.removeAuthorizedAddress.sendTransactionAsync(
|
||||||
from: notOwner,
|
address, { from: notOwner, }
|
||||||
}),
|
|
||||||
RevertReason.OnlyContractOwner,
|
|
||||||
);
|
);
|
||||||
|
expect(tx).to.revertWith(expectedError);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow owner to remove an authorized address', async () => {
|
it('should allow owner to remove an authorized address', async () => {
|
||||||
@ -122,12 +122,11 @@ describe('Authorizable', () => {
|
|||||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||||
);
|
);
|
||||||
const index = new BigNumber(0);
|
const index = new BigNumber(0);
|
||||||
return expectTransactionFailedAsync(
|
const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner);
|
||||||
authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
|
const tx = authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(
|
||||||
from: notOwner,
|
address, index, { from: notOwner, }
|
||||||
}),
|
|
||||||
RevertReason.OnlyContractOwner,
|
|
||||||
);
|
);
|
||||||
|
expect(tx).to.revertWith(expectedError);
|
||||||
});
|
});
|
||||||
it('should throw if index is >= authorities.length', async () => {
|
it('should throw if index is >= authorities.length', async () => {
|
||||||
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { BigNumber } from './configured_bignumber';
|
import { BigNumber } from './configured_bignumber';
|
||||||
import { RevertError } from './revert_error';
|
import { RevertError } from './revert_error';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
// tslint:disable:max-classes-per-file
|
// tslint:disable:max-classes-per-file
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ export class Uint256UnderflowError extends RevertError {
|
|||||||
const types = [
|
const types = [
|
||||||
Uint256OverflowError,
|
Uint256OverflowError,
|
||||||
Uint256UnderflowError,
|
Uint256UnderflowError,
|
||||||
]
|
];
|
||||||
|
|
||||||
// Register the types we've defined.
|
// Register the types we've defined.
|
||||||
for (const type of types) {
|
for (const type of types) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user