aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/token_registry.ts
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-07-03 09:44:37 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-07-03 09:57:33 +0800
commit5b64b3ea937326978b5742ec1b3692ebe5c41991 (patch)
tree34f4029b1985295490479d3da93cae62de5396d1 /packages/contracts/test/token_registry.ts
parentb1dc20bbb35e8fb6370820a94d6f56306453fc4d (diff)
downloaddexon-0x-contracts-5b64b3ea937326978b5742ec1b3692ebe5c41991.tar
dexon-0x-contracts-5b64b3ea937326978b5742ec1b3692ebe5c41991.tar.gz
dexon-0x-contracts-5b64b3ea937326978b5742ec1b3692ebe5c41991.tar.bz2
dexon-0x-contracts-5b64b3ea937326978b5742ec1b3692ebe5c41991.tar.lz
dexon-0x-contracts-5b64b3ea937326978b5742ec1b3692ebe5c41991.tar.xz
dexon-0x-contracts-5b64b3ea937326978b5742ec1b3692ebe5c41991.tar.zst
dexon-0x-contracts-5b64b3ea937326978b5742ec1b3692ebe5c41991.zip
Improve robustness of revert reason assertions
Diffstat (limited to 'packages/contracts/test/token_registry.ts')
-rw-r--r--packages/contracts/test/token_registry.ts32
1 files changed, 15 insertions, 17 deletions
diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts
index 32f8cdee3..7cc43be9b 100644
--- a/packages/contracts/test/token_registry.ts
+++ b/packages/contracts/test/token_registry.ts
@@ -7,7 +7,7 @@ import * as _ from 'lodash';
import { TokenRegistryContract } from '../generated_contract_wrappers/token_registry';
import { artifacts } from './utils/artifacts';
-import { expectRevertOrAlwaysFailingTransactionAsync } from './utils/assertions';
+import { expectTransactionFailedWithoutReasonAsync } from './utils/assertions';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { TokenRegWrapper } from './utils/token_registry_wrapper';
@@ -75,7 +75,7 @@ describe('TokenRegistry', () => {
describe('addToken', () => {
it('should throw when not called by owner', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(tokenRegWrapper.addTokenAsync(token1, notOwner));
+ return expectTransactionFailedWithoutReasonAsync(tokenRegWrapper.addTokenAsync(token1, notOwner));
});
it('should add token metadata when called by owner', async () => {
@@ -87,20 +87,18 @@ describe('TokenRegistry', () => {
it('should throw if token already exists', async () => {
await tokenRegWrapper.addTokenAsync(token1, owner);
- return expectRevertOrAlwaysFailingTransactionAsync(tokenRegWrapper.addTokenAsync(token1, owner));
+ return expectTransactionFailedWithoutReasonAsync(tokenRegWrapper.addTokenAsync(token1, owner));
});
it('should throw if token address is null', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(tokenRegWrapper.addTokenAsync(nullToken, owner));
+ return expectTransactionFailedWithoutReasonAsync(tokenRegWrapper.addTokenAsync(nullToken, owner));
});
it('should throw if name already exists', async () => {
await tokenRegWrapper.addTokenAsync(token1, owner);
const duplicateNameToken = _.assign({}, token2, { name: token1.name });
- return expectRevertOrAlwaysFailingTransactionAsync(
- tokenRegWrapper.addTokenAsync(duplicateNameToken, owner),
- );
+ return expectTransactionFailedWithoutReasonAsync(tokenRegWrapper.addTokenAsync(duplicateNameToken, owner));
});
it('should throw if symbol already exists', async () => {
@@ -109,7 +107,7 @@ describe('TokenRegistry', () => {
symbol: token1.symbol,
});
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenRegWrapper.addTokenAsync(duplicateSymbolToken, owner),
);
});
@@ -136,7 +134,7 @@ describe('TokenRegistry', () => {
describe('setTokenName', () => {
it('should throw when not called by owner', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, { from: notOwner }),
);
});
@@ -162,13 +160,13 @@ describe('TokenRegistry', () => {
it('should throw if the name already exists', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, { from: owner }),
);
});
it('should throw if token does not exist', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.setTokenName.sendTransactionAsync(nullToken.address, token2.name, { from: owner }),
);
});
@@ -176,7 +174,7 @@ describe('TokenRegistry', () => {
describe('setTokenSymbol', () => {
it('should throw when not called by owner', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, {
from: notOwner,
}),
@@ -202,7 +200,7 @@ describe('TokenRegistry', () => {
it('should throw if the symbol already exists', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, {
from: owner,
}),
@@ -210,7 +208,7 @@ describe('TokenRegistry', () => {
});
it('should throw if token does not exist', async () => {
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.setTokenSymbol.sendTransactionAsync(nullToken.address, token2.symbol, {
from: owner,
}),
@@ -221,7 +219,7 @@ describe('TokenRegistry', () => {
describe('removeToken', () => {
it('should throw if not called by owner', async () => {
const index = new BigNumber(0);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.removeToken.sendTransactionAsync(token1.address, index, { from: notOwner }),
);
});
@@ -240,7 +238,7 @@ describe('TokenRegistry', () => {
it('should throw if token does not exist', async () => {
const index = new BigNumber(0);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.removeToken.sendTransactionAsync(nullToken.address, index, { from: owner }),
);
});
@@ -248,7 +246,7 @@ describe('TokenRegistry', () => {
it('should throw if token at given index does not match address', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner);
const incorrectIndex = new BigNumber(0);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectTransactionFailedWithoutReasonAsync(
tokenReg.removeToken.sendTransactionAsync(token2.address, incorrectIndex, { from: owner }),
);
});