Fix errors with new testrpc version

This commit is contained in:
Amir Bandeali
2017-12-04 16:58:15 -08:00
parent 7008e882c0
commit e6862e9739
8 changed files with 45 additions and 44 deletions

View File

@@ -422,7 +422,7 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18), 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 () => { 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.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
order.params.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS')); 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 () => { it('should throw if makerTokenAmount is 0', async () => {
@@ -440,7 +440,7 @@ contract('Exchange', (accounts: string[]) => {
makerTokenAmount: new BigNumber(0), 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 () => { it('should throw if takerTokenAmount is 0', async () => {
@@ -448,14 +448,14 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: new BigNumber(0), 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 () => { it('should throw if fillTakerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync(); order = await orderFactory.newSignedOrderAsync();
return expect(exWrapper.fillOrderAsync(order, taker, {fillTakerTokenAmount: new BigNumber(0)})) 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 \ 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})) 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 \ 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})) 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 \ it('should not change balances if maker allowances are too low to fill order and \
@@ -520,7 +520,7 @@ contract('Exchange', (accounts: string[]) => {
async () => { async () => {
await rep.approve(TokenTransferProxy.address, 0, {from: maker}); await rep.approve(TokenTransferProxy.address, 0, {from: maker});
expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true})) 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}); await rep.approve(TokenTransferProxy.address, INITIAL_ALLOWANCE, {from: maker});
}); });
@@ -540,7 +540,7 @@ contract('Exchange', (accounts: string[]) => {
async () => { async () => {
await dgd.approve(TokenTransferProxy.address, 0, {from: taker}); await dgd.approve(TokenTransferProxy.address, 0, {from: taker});
expect(exWrapper.fillOrderAsync(order, taker, {shouldThrowOnInsufficientBalanceOrAllowance: true})) 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}); 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 () => { 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 () => { it('should throw if makerTokenAmount is 0', async () => {
@@ -659,7 +659,7 @@ contract('Exchange', (accounts: string[]) => {
makerTokenAmount: new BigNumber(0), 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 () => { it('should throw if takerTokenAmount is 0', async () => {
@@ -667,14 +667,14 @@ contract('Exchange', (accounts: string[]) => {
takerTokenAmount: new BigNumber(0), 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 () => { it('should throw if cancelTakerTokenAmount is 0', async () => {
order = await orderFactory.newSignedOrderAsync(); order = await orderFactory.newSignedOrderAsync();
return expect(exWrapper.cancelOrderAsync(order, maker, {cancelTakerTokenAmount: new BigNumber(0)})) 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 () => { it('should be able to cancel a full order', async () => {

View File

@@ -133,7 +133,7 @@ contract('Exchange', (accounts: string[]) => {
}); });
return expect(exWrapper.fillOrKillOrderAsync(order, taker)) 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 () => { 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)}); await exWrapper.fillOrderAsync(order, from, {fillTakerTokenAmount: order.params.takerTokenAmount.div(2)});
return expect(exWrapper.fillOrKillOrderAsync(order, taker)) 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); await exWrapper.fillOrKillOrderAsync(orders[0], taker);
return expect(exWrapper.batchFillOrKillOrdersAsync(orders, taker, {fillTakerTokenAmounts})) 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( return expect(
exWrapper.fillOrdersUpToAsync( exWrapper.fillOrdersUpToAsync(
orders, taker, {fillTakerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18)}), orders, taker, {fillTakerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18)}),
).to.be.rejectedWith(constants.INVALID_OPCODE); ).to.be.rejectedWith(constants.REVERT);
}); });
}); });

View File

@@ -44,7 +44,7 @@ contract('MultiSigWalletWithTimeLock', (accounts: string[]) => {
describe('changeTimeLock', () => { describe('changeTimeLock', () => {
it('should throw when not called by wallet', async () => { it('should throw when not called by wallet', async () => {
return expect(multiSig.changeTimeLock(SECONDS_TIME_LOCKED, {from: owners[0]})) 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 () => { it('should throw without enough confirmations', async () => {
@@ -58,7 +58,7 @@ contract('MultiSigWalletWithTimeLock', (accounts: string[]) => {
const subRes = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams); const subRes = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
txId = subRes.logs[0].args.transactionId.toNumber(); 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 () => { 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]}); const confRes = await multiSig.confirmTransaction(txId, {from: owners[1]});
expect(confRes.logs).to.have.length(2); 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 () => { it('should execute if it has enough confirmations and is past the time lock', async () => {

View File

@@ -44,7 +44,7 @@ contract('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', (accounts: s
it('should throw if data is not for removeAuthorizedAddress', async () => { it('should throw if data is not for removeAuthorizedAddress', async () => {
const data = MultiSigWrapper.encodeFnArgs('addAuthorizedAddress', PROXY_ABI, [owners[0]]); const data = MultiSigWrapper.encodeFnArgs('addAuthorizedAddress', PROXY_ABI, [owners[0]]);
return expect(multiSig.isFunctionRemoveAuthorizedAddress.call(data)) 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 () => { 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 res = await multiSigWrapper.submitTransactionAsync(validDestination, owners[0], dataParams);
const txId = res.logs[0].args.transactionId.toString(); 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 () => { 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); const isConfirmed = await multiSig.isConfirmed.call(txId);
expect(isConfirmed).to.be.true(); 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 () => { 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); const isConfirmed = await multiSig.isConfirmed.call(txId);
expect(isConfirmed).to.be.true(); 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 () => { 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 tx = await multiSig.transactions.call(txId);
const isExecuted = tx[3]; const isExecuted = tx[3];
expect(isExecuted).to.be.true(); 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);
}); });
}); });
}); });

View File

@@ -58,7 +58,7 @@ contract('TokenRegistry', (accounts: string[]) => {
describe('addToken', () => { describe('addToken', () => {
it('should throw when not called by owner', async () => { 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 () => { 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 () => { it('should throw if token already exists', async () => {
await tokenRegWrapper.addTokenAsync(token1, owner); 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 () => { 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 () => { it('should throw if name already exists', async () => {
@@ -82,7 +82,7 @@ contract('TokenRegistry', (accounts: string[]) => {
const duplicateNameToken = _.assign({}, token2, {name: token1.name}); const duplicateNameToken = _.assign({}, token2, {name: token1.name});
return expect(tokenRegWrapper.addTokenAsync(duplicateNameToken, owner)) 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 () => { it('should throw if symbol already exists', async () => {
@@ -90,7 +90,7 @@ contract('TokenRegistry', (accounts: string[]) => {
const duplicateSymbolToken = _.assign({}, token2, {symbol: token1.symbol}); const duplicateSymbolToken = _.assign({}, token2, {symbol: token1.symbol});
return expect(tokenRegWrapper.addTokenAsync(duplicateSymbolToken, owner)) 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', () => { describe('setTokenName', () => {
it('should throw when not called by owner', async () => { it('should throw when not called by owner', async () => {
return expect(tokenReg.setTokenName(token1.address, token2.name, {from: notOwner})) 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 () => { it('should change the token name when called by owner', async () => {
@@ -137,19 +137,19 @@ contract('TokenRegistry', (accounts: string[]) => {
await tokenRegWrapper.addTokenAsync(token2, owner); await tokenRegWrapper.addTokenAsync(token2, owner);
return expect(tokenReg.setTokenName(token1.address, token2.name, {from: 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 () => { it('should throw if token does not exist', async () => {
return expect(tokenReg.setTokenName(nullToken.address, token2.name, {from: owner})) return expect(tokenReg.setTokenName(nullToken.address, token2.name, {from: owner}))
.to.be.rejectedWith(constants.INVALID_OPCODE); .to.be.rejectedWith(constants.REVERT);
}); });
}); });
describe('setTokenSymbol', () => { describe('setTokenSymbol', () => {
it('should throw when not called by owner', async () => { it('should throw when not called by owner', async () => {
return expect(tokenReg.setTokenSymbol(token1.address, token2.symbol, {from: notOwner})) 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 () => { it('should change the token symbol when called by owner', async () => {
@@ -170,12 +170,12 @@ contract('TokenRegistry', (accounts: string[]) => {
await tokenRegWrapper.addTokenAsync(token2, owner); await tokenRegWrapper.addTokenAsync(token2, owner);
return expect(tokenReg.setTokenSymbol(token1.address, token2.symbol, {from: 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 () => { it('should throw if token does not exist', async () => {
return expect(tokenReg.setTokenSymbol(nullToken.address, token2.symbol, {from: owner})) 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 () => { it('should throw if not called by owner', async () => {
const index = 0; const index = 0;
return expect(tokenReg.removeToken(token1.address, index, {from: notOwner})) 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 () => { 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 () => { it('should throw if token does not exist', async () => {
const index = 0; const index = 0;
return expect(tokenReg.removeToken(nullToken.address, index, {from: owner})) 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 () => { it('should throw if token at given index does not match address', async () => {
await tokenRegWrapper.addTokenAsync(token2, owner); await tokenRegWrapper.addTokenAsync(token2, owner);
const incorrectIndex = 0; const incorrectIndex = 0;
return expect(tokenReg.removeToken(token2.address, incorrectIndex, {from: owner})) return expect(tokenReg.removeToken(token2.address, incorrectIndex, {from: owner}))
.to.be.rejectedWith(constants.INVALID_OPCODE); .to.be.rejectedWith(constants.REVERT);
}); });
}); });

View File

@@ -23,7 +23,7 @@ contract('TokenTransferProxy', (accounts: string[]) => {
describe('addAuthorizedAddress', () => { describe('addAuthorizedAddress', () => {
it('should throw if not called by owner', async () => { it('should throw if not called by owner', async () => {
return expect(tokenTransferProxy.addAuthorizedAddress(notOwner, {from: notOwner})) 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 () => { 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 () => { it('should throw if owner attempts to authorize a duplicate address', async () => {
return expect(tokenTransferProxy.addAuthorizedAddress(authorized, {from: owner})) return expect(tokenTransferProxy.addAuthorizedAddress(authorized, {from: owner}))
.to.be.rejectedWith(constants.INVALID_OPCODE); .to.be.rejectedWith(constants.REVERT);
}); });
}); });
describe('removeAuthorizedAddress', () => { describe('removeAuthorizedAddress', () => {
it('should throw if not called by owner', async () => { it('should throw if not called by owner', async () => {
return expect(tokenTransferProxy.removeAuthorizedAddress(authorized, {from: notOwner})) 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 () => { 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 () => { it('should throw if owner attempts to remove an address that is not authorized', async () => {
return expect(tokenTransferProxy.removeAuthorizedAddress(notAuthorized, {from: owner})) return expect(tokenTransferProxy.removeAuthorizedAddress(notAuthorized, {from: owner}))
.to.be.rejectedWith(constants.INVALID_OPCODE); .to.be.rejectedWith(constants.REVERT);
}); });
}); });

View File

@@ -46,7 +46,7 @@ contract('TokenTransferProxy', (accounts: string[]) => {
describe('transferFrom', () => { describe('transferFrom', () => {
it('should throw when called by an unauthorized address', async () => { it('should throw when called by an unauthorized address', async () => {
expect(tokenTransferProxy.transferFrom(rep.address, accounts[0], accounts[1], 1000, {from: notAuthorized})) 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 () => { it('should allow an authorized address to transfer', async () => {

View File

@@ -1,4 +1,5 @@
export const constants = { export const constants = {
NULL_BYTES: '0x', NULL_BYTES: '0x',
INVALID_OPCODE: 'invalid opcode', INVALID_OPCODE: 'invalid opcode',
REVERT: 'revert',
}; };