aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-21 23:23:59 +0800
committerFabio Berger <me@fabioberger.com>2018-06-21 23:23:59 +0800
commitada5428df7f056293d826d28362f8be08874771c (patch)
tree1774c62453dbdae9f51a8f0e23bf115871fcb3a1 /packages/contracts
parent7869c19245c4f5c69bda8726b66df405aca8754c (diff)
downloaddexon-sol-tools-ada5428df7f056293d826d28362f8be08874771c.tar
dexon-sol-tools-ada5428df7f056293d826d28362f8be08874771c.tar.gz
dexon-sol-tools-ada5428df7f056293d826d28362f8be08874771c.tar.bz2
dexon-sol-tools-ada5428df7f056293d826d28362f8be08874771c.tar.lz
dexon-sol-tools-ada5428df7f056293d826d28362f8be08874771c.tar.xz
dexon-sol-tools-ada5428df7f056293d826d28362f8be08874771c.tar.zst
dexon-sol-tools-ada5428df7f056293d826d28362f8be08874771c.zip
Check revert reasons in Authorizable tests
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/src/utils/types.ts1
-rw-r--r--packages/contracts/test/asset_proxy/authorizable.ts20
2 files changed, 15 insertions, 6 deletions
diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts
index da8ea588f..db590213c 100644
--- a/packages/contracts/src/utils/types.ts
+++ b/packages/contracts/src/utils/types.ts
@@ -181,4 +181,5 @@ export enum ContractLibErrors {
TargetAlreadyAuthorized = 'TARGET_ALREADY_AUTHORIZED',
IndexOutOfBounds = 'INDEX_OUT_OF_BOUNDS',
AuthorizedAddressMismatch = 'AUTHORIZED_ADDRESS_MISMATCH',
+ OnlyContractOwner = 'ONLY_CONTRACT_OWNER',
}
diff --git a/packages/contracts/test/asset_proxy/authorizable.ts b/packages/contracts/test/asset_proxy/authorizable.ts
index 347d060d6..9896895bd 100644
--- a/packages/contracts/test/asset_proxy/authorizable.ts
+++ b/packages/contracts/test/asset_proxy/authorizable.ts
@@ -4,16 +4,20 @@ import 'make-promises-safe';
import { MixinAuthorizableContract } from '../../src/generated_contract_wrappers/mixin_authorizable';
import { artifacts } from '../../src/utils/artifacts';
-import { expectRevertOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions';
+import {
+ expectRevertOrAlwaysFailingTransactionAsync,
+ expectRevertReasonOrAlwaysFailingTransactionAsync,
+} from '../../src/utils/assertions';
import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
+import { ContractLibErrors } from '../../src/utils/types';
import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
-describe('Authorizable', () => {
+describe.only('Authorizable', () => {
let owner: string;
let notOwner: string;
let address: string;
@@ -43,8 +47,9 @@ describe('Authorizable', () => {
});
describe('addAuthorizedAddress', () => {
it('should throw if not called by owner', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectRevertReasonOrAlwaysFailingTransactionAsync(
authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }),
+ ContractLibErrors.OnlyContractOwner,
);
});
it('should allow owner to add an authorized address', async () => {
@@ -60,8 +65,9 @@ describe('Authorizable', () => {
await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectRevertReasonOrAlwaysFailingTransactionAsync(
authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
+ ContractLibErrors.TargetAlreadyAuthorized,
);
});
});
@@ -72,10 +78,11 @@ describe('Authorizable', () => {
await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
constants.AWAIT_TRANSACTION_MINED_MS,
);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectRevertReasonOrAlwaysFailingTransactionAsync(
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
from: notOwner,
}),
+ ContractLibErrors.OnlyContractOwner,
);
});
@@ -95,10 +102,11 @@ describe('Authorizable', () => {
});
it('should throw if owner attempts to remove an address that is not authorized', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectRevertReasonOrAlwaysFailingTransactionAsync(
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
from: owner,
}),
+ ContractLibErrors.TargetNotAuthorized,
);
});
});