aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2017-12-05 08:58:15 +0800
committerAmir Bandeali <abandeali1@gmail.com>2017-12-13 07:02:04 +0800
commite6862e973983d478b7683425983f18b4680dd238 (patch)
tree973e558090eb66357ea63e63d748732961499e0b
parent7008e882c0508939da117cd90fe06e7006b85300 (diff)
downloaddexon-sol-tools-e6862e973983d478b7683425983f18b4680dd238.tar.gz
dexon-sol-tools-e6862e973983d478b7683425983f18b4680dd238.tar.zst
dexon-sol-tools-e6862e973983d478b7683425983f18b4680dd238.zip
Fix errors with new testrpc version
-rw-r--r--packages/contracts/test/ts/exchange/core.ts26
-rw-r--r--packages/contracts/test/ts/exchange/wrapper.ts8
-rw-r--r--packages/contracts/test/ts/multi_sig_with_time_lock.ts6
-rw-r--r--packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts10
-rw-r--r--packages/contracts/test/ts/token_registry.ts28
-rw-r--r--packages/contracts/test/ts/token_transfer_proxy/auth.ts8
-rw-r--r--packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts2
-rw-r--r--packages/contracts/util/constants.ts1
8 files changed, 45 insertions, 44 deletions
diff --git a/packages/contracts/test/ts/exchange/core.ts b/packages/contracts/test/ts/exchange/core.ts
index daf46ca37..e4aa74c32 100644
--- a/packages/contracts/test/ts/exchange/core.ts
+++ b/packages/contracts/test/ts/exchange/core.ts
@@ -422,7 +422,7 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if signature is invalid', async () => {
@@ -432,7 +432,7 @@ contract('Exchange', (accounts: string[]) => {
order.params.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
order.params.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
- return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if makerTokenAmount is 0', async () => {
@@ -440,7 +440,7 @@ contract('Exchange', (accounts: string[]) => {
makerTokenAmount: new BigNumber(0),
});
- return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if takerTokenAmount is 0', async () => {
@@ -448,14 +448,14 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: new BigNumber(0),
});
- return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if fillTakerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync();
return expect(exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount: new BigNumber(0)}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if maker balances are too low to fill order and \
@@ -478,7 +478,7 @@ contract('Exchange', (accounts: string[]) => {
});
return expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if taker balances are too low to fill order and \
@@ -501,7 +501,7 @@ contract('Exchange', (accounts: string[]) => {
});
return expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if maker allowances are too low to fill order and \
@@ -520,7 +520,7 @@ contract('Exchange', (accounts: string[]) => {
async () => {
await rep.approve(TokenTransferProxy.address, 0, {from: maker});
expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
await rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: maker});
});
@@ -540,7 +540,7 @@ contract('Exchange', (accounts: string[]) => {
async () => {
await dgd.approve(TokenTransferProxy.address, 0, {from: taker});
expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
await dgd.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: taker});
});
@@ -651,7 +651,7 @@ contract('Exchange', (accounts: string[]) => {
});
it('should throw if not sent by maker', async () => {
- return expect(exWrapper.cancelOrderAsync(order, taker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.cancelOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if makerTokenAmount is 0', async () => {
@@ -659,7 +659,7 @@ contract('Exchange', (accounts: string[]) => {
makerTokenAmount: new BigNumber(0),
});
- return expect(exWrapper.cancelOrderAsync(order, maker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.cancelOrderAsync(order, maker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if takerTokenAmount is 0', async () => {
@@ -667,14 +667,14 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: new BigNumber(0),
});
- return expect(exWrapper.cancelOrderAsync(order, maker)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(exWrapper.cancelOrderAsync(order, maker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if cancelTakerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync();
return expect(exWrapper.cancelOrderAsync(order, maker, {cancelTakerTokenAmount: new BigNumber(0)}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should be able to cancel a full order', async () => {
diff --git a/packages/contracts/test/ts/exchange/wrapper.ts b/packages/contracts/test/ts/exchange/wrapper.ts
index c40d60104..3097f6887 100644
--- a/packages/contracts/test/ts/exchange/wrapper.ts
+++ b/packages/contracts/test/ts/exchange/wrapper.ts
@@ -133,7 +133,7 @@ contract('Exchange', (accounts: string[]) => {
});
return expect(exWrapper.fillOrKillOrderAsync(order, taker))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should throw if entire fillTakerTokenAmount not filled', async () => {
@@ -143,7 +143,7 @@ contract('Exchange', (accounts: string[]) => {
await exWrapper.fillOrderAsync(order, from, {fillTakerTokenAmount: order.params.takerTokenAmount.div(2)});
return expect(exWrapper.fillOrKillOrderAsync(order, taker))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
});
@@ -237,7 +237,7 @@ contract('Exchange', (accounts: string[]) => {
await exWrapper.fillOrKillOrderAsync(orders[0], taker);
return expect(exWrapper.batchFillOrKillOrdersAsync(orders, taker, {fillTakerTokenAmounts}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
});
@@ -302,7 +302,7 @@ contract('Exchange', (accounts: string[]) => {
return expect(
exWrapper.fillOrdersUpToAsync(
orders, taker, {fillTakerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18)}),
- ).to.be.rejectedWith(constants.INVALID_OPCODE);
+ ).to.be.rejectedWith(constants.REVERT);
});
});
diff --git a/packages/contracts/test/ts/multi_sig_with_time_lock.ts b/packages/contracts/test/ts/multi_sig_with_time_lock.ts
index 6dd4dc3b2..84eb21b4a 100644
--- a/packages/contracts/test/ts/multi_sig_with_time_lock.ts
+++ b/packages/contracts/test/ts/multi_sig_with_time_lock.ts
@@ -44,7 +44,7 @@ contract('MultiSigWalletWithTimeLock', (accounts: string[]) => {
describe('changeTimeLock', () => {
it('should throw when not called by wallet', async () => {
return expect(multiSig.changeTimeLock(SECONDS_TIME_LOCKED, {from: owners[0]}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should throw without enough confirmations', async () => {
@@ -58,7 +58,7 @@ contract('MultiSigWalletWithTimeLock', (accounts: string[]) => {
const subRes = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
txId = subRes.logs[0].args.transactionId.toNumber();
- return expect(multiSig.executeTransaction(txId)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.executeTransaction(txId)).to.be.rejectedWith(constants.REVERT);
});
it('should set confirmation time with enough confirmations', async () => {
@@ -97,7 +97,7 @@ contract('MultiSigWalletWithTimeLock', (accounts: string[]) => {
const confRes = await multiSig.confirmTransaction(txId, {from: owners[1]});
expect(confRes.logs).to.have.length(2);
- return expect(multiSig.executeTransaction(txId)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.executeTransaction(txId)).to.be.rejectedWith(constants.REVERT);
});
it('should execute if it has enough confirmations and is past the time lock', async () => {
diff --git a/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts b/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts
index 97ccac2bd..6f7aaa6cd 100644
--- a/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts
+++ b/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts
@@ -44,7 +44,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
it('should throw if data is not for removeAuthorizedAddress', async () => {
const data = MultiSigWrapper.encodeFnArgs('addAuthorizedAddress', PROXY_ABI, [owners[0]]);
return expect(multiSig.isFunctionRemoveAuthorizedAddress.call(data))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should return true if data is for removeAuthorizedAddress', async () => {
@@ -64,7 +64,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
const res = await multiSigWrapper.submitTransactionAsync(validDestination, owners[0], dataParams);
const txId = res.logs[0].args.transactionId.toString();
- return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if tx destination is not the tokenTransferProxy', async () => {
@@ -81,7 +81,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
const isConfirmed = await multiSig.isConfirmed.call(txId);
expect(isConfirmed).to.be.true();
- return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if tx data is not for removeAuthorizedAddress', async () => {
@@ -96,7 +96,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
const isConfirmed = await multiSig.isConfirmed.call(txId);
expect(isConfirmed).to.be.true();
- return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.REVERT);
});
it('should execute removeAuthorizedAddress for valid tokenTransferProxy if fully confirmed', async () => {
@@ -131,7 +131,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
const tx = await multiSig.transactions.call(txId);
const isExecuted = tx[3];
expect(isExecuted).to.be.true();
- return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(multiSig.executeRemoveAuthorizedAddress(txId)).to.be.rejectedWith(constants.REVERT);
});
});
});
diff --git a/packages/contracts/test/ts/token_registry.ts b/packages/contracts/test/ts/token_registry.ts
index ed0bbf55b..36f3edcfc 100644
--- a/packages/contracts/test/ts/token_registry.ts
+++ b/packages/contracts/test/ts/token_registry.ts
@@ -58,7 +58,7 @@ contract('TokenRegistry', (accounts: string[]) => {
describe('addToken', () => {
it('should throw when not called by owner', async () => {
- return expect(tokenRegWrapper.addTokenAsync(token1, notOwner)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenRegWrapper.addTokenAsync(token1, notOwner)).to.be.rejectedWith(constants.REVERT);
});
it('should add token metadata when called by owner', async () => {
@@ -70,11 +70,11 @@ contract('TokenRegistry', (accounts: string[]) => {
it('should throw if token already exists', async () => {
await tokenRegWrapper.addTokenAsync(token1, owner);
- return expect(tokenRegWrapper.addTokenAsync(token1, owner)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenRegWrapper.addTokenAsync(token1, owner)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if token address is null', async () => {
- return expect(tokenRegWrapper.addTokenAsync(nullToken, owner)).to.be.rejectedWith(constants.INVALID_OPCODE);
+ return expect(tokenRegWrapper.addTokenAsync(nullToken, owner)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if name already exists', async () => {
@@ -82,7 +82,7 @@ contract('TokenRegistry', (accounts: string[]) => {
const duplicateNameToken = _.assign({}, token2, {name: token1.name});
return expect(tokenRegWrapper.addTokenAsync(duplicateNameToken, owner))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should throw if symbol already exists', async () => {
@@ -90,7 +90,7 @@ contract('TokenRegistry', (accounts: string[]) => {
const duplicateSymbolToken = _.assign({}, token2, {symbol: token1.symbol});
return expect(tokenRegWrapper.addTokenAsync(duplicateSymbolToken, owner))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
});
@@ -116,7 +116,7 @@ contract('TokenRegistry', (accounts: string[]) => {
describe('setTokenName', () => {
it('should throw when not called by owner', async () => {
return expect(tokenReg.setTokenName(token1.address, token2.name, {from: notOwner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should change the token name when called by owner', async () => {
@@ -137,19 +137,19 @@ contract('TokenRegistry', (accounts: string[]) => {
await tokenRegWrapper.addTokenAsync(token2, owner);
return expect(tokenReg.setTokenName(token1.address, token2.name, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should throw if token does not exist', async () => {
return expect(tokenReg.setTokenName(nullToken.address, token2.name, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
});
describe('setTokenSymbol', () => {
it('should throw when not called by owner', async () => {
return expect(tokenReg.setTokenSymbol(token1.address, token2.symbol, {from: notOwner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should change the token symbol when called by owner', async () => {
@@ -170,12 +170,12 @@ contract('TokenRegistry', (accounts: string[]) => {
await tokenRegWrapper.addTokenAsync(token2, owner);
return expect(tokenReg.setTokenSymbol(token1.address, token2.symbol, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should throw if token does not exist', async () => {
return expect(tokenReg.setTokenSymbol(nullToken.address, token2.symbol, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
});
@@ -183,7 +183,7 @@ contract('TokenRegistry', (accounts: string[]) => {
it('should throw if not called by owner', async () => {
const index = 0;
return expect(tokenReg.removeToken(token1.address, index, {from: notOwner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should remove token metadata when called by owner', async () => {
@@ -197,14 +197,14 @@ contract('TokenRegistry', (accounts: string[]) => {
it('should throw if token does not exist', async () => {
const index = 0;
return expect(tokenReg.removeToken(nullToken.address, index, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should throw if token at given index does not match address', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner);
const incorrectIndex = 0;
return expect(tokenReg.removeToken(token2.address, incorrectIndex, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
});
diff --git a/packages/contracts/test/ts/token_transfer_proxy/auth.ts b/packages/contracts/test/ts/token_transfer_proxy/auth.ts
index 785fbc016..7c0a3d231 100644
--- a/packages/contracts/test/ts/token_transfer_proxy/auth.ts
+++ b/packages/contracts/test/ts/token_transfer_proxy/auth.ts
@@ -23,7 +23,7 @@ contract('TokenTransferProxy', (accounts: string[]) => {
describe('addAuthorizedAddress', () => {
it('should throw if not called by owner', async () => {
return expect(tokenTransferProxy.addAuthorizedAddress(notOwner, {from: notOwner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should allow owner to add an authorized address', async () => {
@@ -36,14 +36,14 @@ contract('TokenTransferProxy', (accounts: string[]) => {
it('should throw if owner attempts to authorize a duplicate address', async () => {
return expect(tokenTransferProxy.addAuthorizedAddress(authorized, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
});
describe('removeAuthorizedAddress', () => {
it('should throw if not called by owner', async () => {
return expect(tokenTransferProxy.removeAuthorizedAddress(authorized, {from: notOwner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should allow owner to remove an authorized address', async () => {
@@ -57,7 +57,7 @@ contract('TokenTransferProxy', (accounts: string[]) => {
it('should throw if owner attempts to remove an address that is not authorized', async () => {
return expect(tokenTransferProxy.removeAuthorizedAddress(notAuthorized, {from: owner}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
});
diff --git a/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts b/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts
index 6e0bfdc1a..8b40bfb1e 100644
--- a/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts
+++ b/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts
@@ -46,7 +46,7 @@ contract('TokenTransferProxy', (accounts: string[]) => {
describe('transferFrom', () => {
it('should throw when called by an unauthorized address', async () => {
expect(tokenTransferProxy.transferFrom(rep.address, accounts[0], accounts[1], 1000, {from: notAuthorized}))
- .to.be.rejectedWith(constants.INVALID_OPCODE);
+ .to.be.rejectedWith(constants.REVERT);
});
it('should allow an authorized address to transfer', async () => {
diff --git a/packages/contracts/util/constants.ts b/packages/contracts/util/constants.ts
index 5beebc68c..733ad2312 100644
--- a/packages/contracts/util/constants.ts
+++ b/packages/contracts/util/constants.ts
@@ -1,4 +1,5 @@
export const constants = {
NULL_BYTES: '0x',
INVALID_OPCODE: 'invalid opcode',
+ REVERT: 'revert',
};