From 8c5c81fe705874376552a9883934fbe90a533236 Mon Sep 17 00:00:00 2001 From: Alex Towle Date: Thu, 1 Aug 2019 15:10:06 -0700 Subject: [PATCH] Change all instances of throw to revert in it tests --- contracts/asset-proxy/test/authorizable.ts | 16 ++++++------ contracts/erc1155/test/erc1155_token.ts | 12 ++++----- .../erc20/test/unlimited_allowance_token.ts | 6 ++--- contracts/erc20/test/weth9.ts | 4 +-- contracts/exchange/test/core.ts | 26 +++++++++---------- contracts/exchange/test/dispatcher.ts | 6 ++--- contracts/exchange/test/fill_order.ts | 26 +++++++++---------- contracts/exchange/test/match_orders.ts | 20 +++++++------- .../exchange/test/signature_validator.ts | 4 +-- contracts/exchange/test/wrapper.ts | 12 ++++----- contracts/multisig/test/asset_proxy_owner.ts | 12 ++++----- .../multisig/test/multi_sig_with_time_lock.ts | 6 ++--- contracts/utils/test/ownable.ts | 2 +- contracts/utils/test/reentrancy_guard.ts | 2 +- contracts/utils/test/safe_math.ts | 6 ++--- 15 files changed, 80 insertions(+), 80 deletions(-) diff --git a/contracts/asset-proxy/test/authorizable.ts b/contracts/asset-proxy/test/authorizable.ts index ee2eff5884..57cd4abf73 100644 --- a/contracts/asset-proxy/test/authorizable.ts +++ b/contracts/asset-proxy/test/authorizable.ts @@ -46,7 +46,7 @@ describe('Authorizable', () => { await blockchainLifecycle.revertAsync(); }); describe('addAuthorizedAddress', () => { - it('should throw if not called by owner', async () => { + it('should revert if not called by owner', async () => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner); const tx = authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }); return expect(tx).to.revertWith(expectedError); @@ -60,7 +60,7 @@ describe('Authorizable', () => { const isAuthorized = await authorizable.authorized.callAsync(address); expect(isAuthorized).to.be.true(); }); - it('should throw if owner attempts to authorize a duplicate address', async () => { + it('should revert if owner attempts to authorize a duplicate address', async () => { await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync( address, { from: owner }, @@ -74,7 +74,7 @@ describe('Authorizable', () => { }); describe('removeAuthorizedAddress', () => { - it('should throw if not called by owner', async () => { + it('should revert if not called by owner', async () => { await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync( address, { from: owner }, @@ -100,7 +100,7 @@ describe('Authorizable', () => { expect(isAuthorized).to.be.false(); }); - it('should throw if owner attempts to remove an address that is not authorized', async () => { + it('should revert if owner attempts to remove an address that is not authorized', async () => { return expectTransactionFailedAsync( authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { from: owner, @@ -111,7 +111,7 @@ describe('Authorizable', () => { }); describe('removeAuthorizedAddressAtIndex', () => { - it('should throw if not called by owner', async () => { + it('should revert if not called by owner', async () => { await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync( address, { from: owner }, @@ -124,7 +124,7 @@ describe('Authorizable', () => { }); return expect(tx).to.revertWith(expectedError); }); - it('should throw if index is >= authorities.length', async () => { + it('should revert if index is >= authorities.length', async () => { await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync( address, { from: owner }, @@ -138,7 +138,7 @@ describe('Authorizable', () => { RevertReason.IndexOutOfBounds, ); }); - it('should throw if owner attempts to remove an address that is not authorized', async () => { + it('should revert if owner attempts to remove an address that is not authorized', async () => { const index = new BigNumber(0); return expectTransactionFailedAsync( authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { @@ -147,7 +147,7 @@ describe('Authorizable', () => { RevertReason.TargetNotAuthorized, ); }); - it('should throw if address at index does not match target', async () => { + it('should revert if address at index does not match target', async () => { const address1 = address; const address2 = notOwner; await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync( diff --git a/contracts/erc1155/test/erc1155_token.ts b/contracts/erc1155/test/erc1155_token.ts index aa57e590b5..29315c065d 100644 --- a/contracts/erc1155/test/erc1155_token.ts +++ b/contracts/erc1155/test/erc1155_token.ts @@ -166,7 +166,7 @@ describe('ERC1155Token', () => { ]; await erc1155Wrapper.assertBalancesAsync(tokenHolders, [tokenToTransfer], expectedFinalBalances); }); - it('should throw if transfer reverts', async () => { + it('should revert if transfer reverts', async () => { // setup test parameters const tokenToTransfer = fungibleToken; const valueToTransfer = spenderInitialFungibleBalance.plus(1); @@ -187,7 +187,7 @@ describe('ERC1155Token', () => { ); return expect(tx).to.revertWith(expectedError); }); - it('should throw if callback reverts', async () => { + it('should revert if callback reverts', async () => { // setup test parameters const tokenToTransfer = fungibleToken; const valueToTransfer = fungibleValueToTransfer; @@ -342,7 +342,7 @@ describe('ERC1155Token', () => { ]; await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances); }); - it('should throw if transfer reverts', async () => { + it('should revert if transfer reverts', async () => { // setup test parameters const tokensToTransfer = [fungibleToken]; const valuesToTransfer = [spenderInitialFungibleBalance.plus(1)]; @@ -363,7 +363,7 @@ describe('ERC1155Token', () => { ); return expect(tx).to.revertWith(expectedError); }); - it('should throw if callback reverts', async () => { + it('should revert if callback reverts', async () => { // setup test parameters const tokensToTransfer = [fungibleToken]; const valuesToTransfer = [fungibleValueToTransfer]; @@ -417,7 +417,7 @@ describe('ERC1155Token', () => { ]; await erc1155Wrapper.assertBalancesAsync(tokenHolders, [tokenToTransfer], expectedFinalBalances); }); - it('should throw if trying to transfer tokens via safeTransferFrom by an unapproved account', async () => { + it('should revert if trying to transfer tokens via safeTransferFrom by an unapproved account', async () => { // check approval not set const isApprovedForAllCheck = await erc1155Wrapper.isApprovedForAllAsync(spender, delegatedSpender); expect(isApprovedForAllCheck).to.be.false(); @@ -470,7 +470,7 @@ describe('ERC1155Token', () => { ]; await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances); }); - it('should throw if trying to transfer tokens via safeBatchTransferFrom by an unapproved account', async () => { + it('should revert if trying to transfer tokens via safeBatchTransferFrom by an unapproved account', async () => { // check approval not set const isApprovedForAllCheck = await erc1155Wrapper.isApprovedForAllAsync(spender, delegatedSpender); expect(isApprovedForAllCheck).to.be.false(); diff --git a/contracts/erc20/test/unlimited_allowance_token.ts b/contracts/erc20/test/unlimited_allowance_token.ts index f0b8e53a46..e31507d7ab 100644 --- a/contracts/erc20/test/unlimited_allowance_token.ts +++ b/contracts/erc20/test/unlimited_allowance_token.ts @@ -54,7 +54,7 @@ describe('UnlimitedAllowanceToken', () => { await blockchainLifecycle.revertAsync(); }); describe('transfer', () => { - it('should throw if owner has insufficient balance', async () => { + it('should revert if owner has insufficient balance', async () => { const ownerBalance = await token.balanceOf.callAsync(owner); const amountToTransfer = ownerBalance.plus(1); return expectContractCallFailedAsync( @@ -89,7 +89,7 @@ describe('UnlimitedAllowanceToken', () => { }); describe('transferFrom', () => { - it('should throw if owner has insufficient balance', async () => { + it('should revert if owner has insufficient balance', async () => { const ownerBalance = await token.balanceOf.callAsync(owner); const amountToTransfer = ownerBalance.plus(1); await web3Wrapper.awaitTransactionSuccessAsync( @@ -104,7 +104,7 @@ describe('UnlimitedAllowanceToken', () => { ); }); - it('should throw if spender has insufficient allowance', async () => { + it('should revert if spender has insufficient allowance', async () => { const ownerBalance = await token.balanceOf.callAsync(owner); const amountToTransfer = ownerBalance; diff --git a/contracts/erc20/test/weth9.ts b/contracts/erc20/test/weth9.ts index 6a3948e2c3..444a8c3ef6 100644 --- a/contracts/erc20/test/weth9.ts +++ b/contracts/erc20/test/weth9.ts @@ -45,7 +45,7 @@ describe('EtherToken', () => { await blockchainLifecycle.revertAsync(); }); describe('deposit', () => { - it('should throw if caller attempts to deposit more Ether than caller balance', async () => { + it('should revert if caller attempts to deposit more Ether than caller balance', async () => { const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account); const ethToDeposit = initEthBalance.plus(1); @@ -74,7 +74,7 @@ describe('EtherToken', () => { }); describe('withdraw', () => { - it('should throw if caller attempts to withdraw greater than caller balance', async () => { + it('should revert if caller attempts to withdraw greater than caller balance', async () => { const initEthTokenBalance = await etherToken.balanceOf.callAsync(account); const ethTokensToWithdraw = initEthTokenBalance.plus(1); diff --git a/contracts/exchange/test/core.ts b/contracts/exchange/test/core.ts index fbcdda23e5..2d5069592e 100644 --- a/contracts/exchange/test/core.ts +++ b/contracts/exchange/test/core.ts @@ -380,7 +380,7 @@ describe('Exchange core', () => { }); }); - it('should throw if fully filled', async () => { + it('should revert if fully filled', async () => { signedOrder = await orderFactory.newSignedOrderAsync(); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress); @@ -423,7 +423,7 @@ describe('Exchange core', () => { ).to.be.bignumber.equal(signedOrder.takerFee); }); - it('should throw if order is expired', async () => { + it('should revert if order is expired', async () => { const currentTimestamp = await getLatestBlockTimestampAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10), @@ -742,14 +742,14 @@ describe('Exchange core', () => { signedOrder = await orderFactory.newSignedOrderAsync(); }); - it('should throw if not sent by maker', async () => { + it('should revert if not sent by maker', async () => { const orderHash = orderHashUtils.getOrderHashHex(signedOrder); const expectedError = new ExchangeRevertErrors.InvalidMakerError(orderHash, takerAddress); const tx = exchangeWrapper.cancelOrderAsync(signedOrder, takerAddress); return expect(tx).to.revertWith(expectedError); }); - it('should throw if makerAssetAmount is 0', async () => { + it('should revert if makerAssetAmount is 0', async () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(0), }); @@ -762,7 +762,7 @@ describe('Exchange core', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw if takerAssetAmount is 0', async () => { + it('should revert if takerAssetAmount is 0', async () => { signedOrder = await orderFactory.newSignedOrderAsync({ takerAssetAmount: new BigNumber(0), }); @@ -800,7 +800,7 @@ describe('Exchange core', () => { expect(orderHashUtils.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash); }); - it('should throw if already cancelled', async () => { + it('should revert if already cancelled', async () => { await exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress); const orderHash = orderHashUtils.getOrderHashHex(signedOrder); const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHash, OrderStatus.Cancelled); @@ -808,7 +808,7 @@ describe('Exchange core', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw if order is expired', async () => { + it('should revert if order is expired', async () => { const currentTimestamp = await getLatestBlockTimestampAsync(); signedOrder = await orderFactory.newSignedOrderAsync({ expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10), @@ -819,7 +819,7 @@ describe('Exchange core', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw if rounding error is greater than 0.1%', async () => { + it('should revert if rounding error is greater than 0.1%', async () => { signedOrder = await orderFactory.newSignedOrderAsync({ makerAssetAmount: new BigNumber(1001), takerAssetAmount: new BigNumber(3), @@ -936,7 +936,7 @@ describe('Exchange core', () => { }); describe('Testing Exchange of ERC721 Tokens', () => { - it('should throw when maker does not own the token with id makerAssetId', async () => { + it('should revert when maker does not own the token with id makerAssetId', async () => { // Construct Exchange parameters const makerAssetId = erc721TakerAssetIds[0]; const takerAssetId = erc721TakerAssetIds[1]; @@ -963,7 +963,7 @@ describe('Exchange core', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw when taker does not own the token with id takerAssetId', async () => { + it('should revert when taker does not own the token with id takerAssetId', async () => { // Construct Exchange parameters const makerAssetId = erc721MakerAssetIds[0]; const takerAssetId = erc721MakerAssetIds[1]; @@ -990,7 +990,7 @@ describe('Exchange core', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw when makerAssetAmount is greater than 1', async () => { + it('should revert when makerAssetAmount is greater than 1', async () => { // Construct Exchange parameters const makerAssetId = erc721MakerAssetIds[0]; const takerAssetId = erc721TakerAssetIds[0]; @@ -1017,7 +1017,7 @@ describe('Exchange core', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw when takerAssetAmount is greater than 1', async () => { + it('should revert when takerAssetAmount is greater than 1', async () => { // Construct Exchange parameters const makerAssetId = erc721MakerAssetIds[0]; const takerAssetId = erc721TakerAssetIds[0]; @@ -1044,7 +1044,7 @@ describe('Exchange core', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw on partial fill', async () => { + it('should revert on partial fill', async () => { // Construct Exchange parameters const makerAssetId = erc721MakerAssetIds[0]; signedOrder = await orderFactory.newSignedOrderAsync({ diff --git a/contracts/exchange/test/dispatcher.ts b/contracts/exchange/test/dispatcher.ts index befb88d601..c547d44f17 100644 --- a/contracts/exchange/test/dispatcher.ts +++ b/contracts/exchange/test/dispatcher.ts @@ -114,7 +114,7 @@ describe('AssetProxyDispatcher', () => { expect(proxyAddress).to.be.equal(erc721Proxy.address); }); - it('should throw if a proxy with the same id is already registered', async () => { + it('should revert if a proxy with the same id is already registered', async () => { // Initial registration await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { from: owner, @@ -134,7 +134,7 @@ describe('AssetProxyDispatcher', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw if requesting address is not owner', async () => { + it('should revert if requesting address is not owner', async () => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner); const tx = assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { from: notOwner, @@ -250,7 +250,7 @@ describe('AssetProxyDispatcher', () => { expect(newBalances).to.deep.equal(erc20Balances); }); - it('should throw if dispatching to unregistered proxy', async () => { + it('should revert if dispatching to unregistered proxy', async () => { // Construct metadata for ERC20 proxy const encodedAssetData = assetDataUtils.encodeERC20AssetData(erc20TokenA.address); // Perform a transfer from makerAddress to takerAddress diff --git a/contracts/exchange/test/fill_order.ts b/contracts/exchange/test/fill_order.ts index 8b119de8d9..9516699405 100644 --- a/contracts/exchange/test/fill_order.ts +++ b/contracts/exchange/test/fill_order.ts @@ -175,7 +175,7 @@ describe('FillOrder Tests', () => { await fillOrderCombinatorialUtils.testFillOrderScenarioSuccessAsync(fillScenario); }); - it('should throw when taker is specified and order is claimed by other', async () => { + it('should revert when taker is specified and order is claimed by other', async () => { const fillScenario = { ...defaultFillScenario, orderScenario: { @@ -186,7 +186,7 @@ describe('FillOrder Tests', () => { await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); }); - it('should throw if makerAssetAmount is 0', async () => { + it('should revert if makerAssetAmount is 0', async () => { const fillScenario = { ...defaultFillScenario, orderScenario: { @@ -198,7 +198,7 @@ describe('FillOrder Tests', () => { await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); }); - it('should throw if takerAssetAmount is 0', async () => { + it('should revert if takerAssetAmount is 0', async () => { const fillScenario = { ...defaultFillScenario, orderScenario: { @@ -210,7 +210,7 @@ describe('FillOrder Tests', () => { await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); }); - it('should throw if takerAssetFillAmount is 0', async () => { + it('should revert if takerAssetFillAmount is 0', async () => { const fillScenario = { ...defaultFillScenario, takerAssetFillAmountScenario: TakerAssetFillAmountScenario.Zero, @@ -218,7 +218,7 @@ describe('FillOrder Tests', () => { await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); }); - it('should throw if an order is expired', async () => { + it('should revert if an order is expired', async () => { const fillScenario = { ...defaultFillScenario, orderScenario: { @@ -331,7 +331,7 @@ describe('FillOrder Tests', () => { await fillOrderCombinatorialUtils.testFillOrderScenarioSuccessAsync(fillScenario); }); - it('should throw if maker balance is too low to fill order', async () => { + it('should revert if maker balance is too low to fill order', async () => { const fillScenario = { ...defaultFillScenario, makerStateScenario: { @@ -342,7 +342,7 @@ describe('FillOrder Tests', () => { await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); }); - it('should throw if taker balance is too low to fill order', async () => { + it('should revert if taker balance is too low to fill order', async () => { const fillScenario = { ...defaultFillScenario, takerStateScenario: { @@ -353,7 +353,7 @@ describe('FillOrder Tests', () => { await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); }); - it('should throw if maker allowances are too low to fill order', async () => { + it('should revert if maker allowances are too low to fill order', async () => { const fillScenario = { ...defaultFillScenario, makerStateScenario: { @@ -364,7 +364,7 @@ describe('FillOrder Tests', () => { await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); }); - it('should throw if taker allowances are too low to fill order', async () => { + it('should revert if taker allowances are too low to fill order', async () => { const fillScenario = { ...defaultFillScenario, takerStateScenario: { @@ -375,7 +375,7 @@ describe('FillOrder Tests', () => { await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); }); - it('should throw if maker fee balance is too low to fill order', async () => { + it('should revert if maker fee balance is too low to fill order', async () => { const fillScenario = { ...defaultFillScenario, makerStateScenario: { @@ -386,7 +386,7 @@ describe('FillOrder Tests', () => { await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); }); - it('should throw if taker fee balance is too low to fill order', async () => { + it('should revert if taker fee balance is too low to fill order', async () => { const fillScenario = { ...defaultFillScenario, takerStateScenario: { @@ -397,7 +397,7 @@ describe('FillOrder Tests', () => { await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); }); - it('should throw if maker fee allowances are too low to fill order', async () => { + it('should revert if maker fee allowances are too low to fill order', async () => { const fillScenario = { ...defaultFillScenario, makerStateScenario: { @@ -408,7 +408,7 @@ describe('FillOrder Tests', () => { await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); }); - it('should throw if taker fee allowances are too low to fill order', async () => { + it('should revert if taker fee allowances are too low to fill order', async () => { const fillScenario = { ...defaultFillScenario, takerStateScenario: { diff --git a/contracts/exchange/test/match_orders.ts b/contracts/exchange/test/match_orders.ts index 1e200778ce..74edbd9acd 100644 --- a/contracts/exchange/test/match_orders.ts +++ b/contracts/exchange/test/match_orders.ts @@ -1286,7 +1286,7 @@ describe('matchOrders', () => { ); }); - it('Should throw if left order is not fillable', async () => { + it('Should revert if left order is not fillable', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), @@ -1305,7 +1305,7 @@ describe('matchOrders', () => { return expect(tx).to.revertWith(expectedError); }); - it('Should throw if right order is not fillable', async () => { + it('Should revert if right order is not fillable', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), @@ -1324,7 +1324,7 @@ describe('matchOrders', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw if there is not a positive spread', async () => { + it('should revert if there is not a positive spread', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), @@ -1342,7 +1342,7 @@ describe('matchOrders', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw if the left maker asset is not equal to the right taker asset ', async () => { + it('should revert if the left maker asset is not equal to the right taker asset ', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), @@ -1373,7 +1373,7 @@ describe('matchOrders', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw if the right maker asset is not equal to the left taker asset', async () => { + it('should revert if the right maker asset is not equal to the left taker asset', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress), @@ -2416,7 +2416,7 @@ describe('matchOrders', () => { ); }); - it('Should throw if left order is not fillable', async () => { + it('Should revert if left order is not fillable', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), @@ -2435,7 +2435,7 @@ describe('matchOrders', () => { return expect(tx).to.revertWith(expectedError); }); - it('Should throw if right order is not fillable', async () => { + it('Should revert if right order is not fillable', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), @@ -2454,7 +2454,7 @@ describe('matchOrders', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw if there is not a positive spread', async () => { + it('should revert if there is not a positive spread', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), @@ -2472,7 +2472,7 @@ describe('matchOrders', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw if the left maker asset is not equal to the right taker asset ', async () => { + it('should revert if the left maker asset is not equal to the right taker asset ', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), @@ -2503,7 +2503,7 @@ describe('matchOrders', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw if the right maker asset is not equal to the left taker asset', async () => { + it('should revert if the right maker asset is not equal to the left taker asset', async () => { // Create orders to match const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress), diff --git a/contracts/exchange/test/signature_validator.ts b/contracts/exchange/test/signature_validator.ts index 6bc75c06c0..ba5b84822d 100644 --- a/contracts/exchange/test/signature_validator.ts +++ b/contracts/exchange/test/signature_validator.ts @@ -495,7 +495,7 @@ describe('MixinSignatureValidator', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw when SignatureType=Validator, signature is valid and validator is not approved', async () => { + it('should revert when SignatureType=Validator, signature is valid and validator is not approved', async () => { // Set approval of signature validator to false await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( validatorWallet.address, @@ -702,7 +702,7 @@ describe('MixinSignatureValidator', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw when SignatureType=Validator, signature is valid and validator is not approved', async () => { + it('should revert when SignatureType=Validator, signature is valid and validator is not approved', async () => { // Set approval of signature validator to false await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( validatorWallet.address, diff --git a/contracts/exchange/test/wrapper.ts b/contracts/exchange/test/wrapper.ts index be30975aef..4d48862012 100644 --- a/contracts/exchange/test/wrapper.ts +++ b/contracts/exchange/test/wrapper.ts @@ -234,7 +234,7 @@ describe('Exchange wrappers', () => { ); }); - it('should throw if a signedOrder is expired', async () => { + it('should revert if a signedOrder is expired', async () => { const currentTimestamp = await getLatestBlockTimestampAsync(); const signedOrder = await orderFactory.newSignedOrderAsync({ expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10), @@ -245,7 +245,7 @@ describe('Exchange wrappers', () => { return expect(tx).to.revertWith(expectedError); }); - it('should throw if entire takerAssetFillAmount not filled', async () => { + it('should revert if entire takerAssetFillAmount not filled', async () => { const signedOrder = await orderFactory.newSignedOrderAsync(); await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { @@ -815,7 +815,7 @@ describe('Exchange wrappers', () => { expect(newBalances).to.be.deep.equal(erc20Balances); }); - it('should throw if a single signedOrder does not fill the expected amount', async () => { + it('should revert if a single signedOrder does not fill the expected amount', async () => { const takerAssetFillAmounts: BigNumber[] = []; _.forEach(signedOrders, signedOrder => { const takerAssetFillAmount = signedOrder.takerAssetAmount.div(2); @@ -922,7 +922,7 @@ describe('Exchange wrappers', () => { expect(newBalances).to.be.deep.equal(erc20Balances); }); - it('should not throw if an order is invalid and fill the remaining orders', async () => { + it('should not revert if an order is invalid and fill the remaining orders', async () => { const makerAssetAddress = erc20TokenA.address; const takerAssetAddress = erc20TokenB.address; @@ -1132,7 +1132,7 @@ describe('Exchange wrappers', () => { expect(newBalances).to.be.deep.equal(erc20Balances); }); - it('should throw when a signedOrder does not use the same takerAssetAddress', async () => { + it('should revert when a signedOrder does not use the same takerAssetAddress', async () => { signedOrders = [ await orderFactory.newSignedOrderAsync(), await orderFactory.newSignedOrderAsync({ @@ -1510,7 +1510,7 @@ describe('Exchange wrappers', () => { expect(newBalances).to.be.deep.equal(erc20Balances); }); - it('should throw when a signedOrder does not use the same makerAssetAddress', async () => { + it('should revert when a signedOrder does not use the same makerAssetAddress', async () => { signedOrders = [ await orderFactory.newSignedOrderAsync(), await orderFactory.newSignedOrderAsync({ diff --git a/contracts/multisig/test/asset_proxy_owner.ts b/contracts/multisig/test/asset_proxy_owner.ts index 62081554be..729449e144 100644 --- a/contracts/multisig/test/asset_proxy_owner.ts +++ b/contracts/multisig/test/asset_proxy_owner.ts @@ -115,7 +115,7 @@ describe('AssetProxyOwner', () => { expect(isErc20ProxyRegistered).to.equal(true); expect(isErc721ProxyRegistered).to.equal(true); }); - it('should throw if a null address is included in assetProxyContracts', async () => { + it('should revert if a null address is included in assetProxyContracts', async () => { const assetProxyContractAddresses = [erc20Proxy.address, constants.NULL_ADDRESS]; return expectContractCreationFailedAsync( (AssetProxyOwnerContract.deployFrom0xArtifactAsync( @@ -158,7 +158,7 @@ describe('AssetProxyOwner', () => { }); describe('registerAssetProxy', () => { - it('should throw if not called by multisig', async () => { + it('should revert if not called by multisig', async () => { const isRegistered = true; return expectTransactionFailedWithoutReasonAsync( testAssetProxyOwner.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, isRegistered, { @@ -338,7 +338,7 @@ describe('AssetProxyOwner', () => { }); describe('executeRemoveAuthorizedAddressAtIndex', () => { - it('should throw without the required confirmations', async () => { + it('should revert without the required confirmations', async () => { const removeAuthorizedAddressAtIndexData = erc20Proxy.removeAuthorizedAddressAtIndex.getABIEncodedTransactionData( authorized, erc20Index, @@ -359,7 +359,7 @@ describe('AssetProxyOwner', () => { ); }); - it('should throw if tx destination is not registered', async () => { + it('should revert if tx destination is not registered', async () => { const removeAuthorizedAddressAtIndexData = erc721Proxy.removeAuthorizedAddressAtIndex.getABIEncodedTransactionData( authorized, erc721Index, @@ -382,7 +382,7 @@ describe('AssetProxyOwner', () => { ); }); - it('should throw if tx data is not for removeAuthorizedAddressAtIndex', async () => { + it('should revert if tx data is not for removeAuthorizedAddressAtIndex', async () => { const newAuthorized = owners[1]; const addAuthorizedAddressData = erc20Proxy.addAuthorizedAddress.getABIEncodedTransactionData( newAuthorized, @@ -468,7 +468,7 @@ describe('AssetProxyOwner', () => { expect(isAuthorizedAfter).to.equal(false); }); - it('should throw if already executed', async () => { + it('should revert if already executed', async () => { const removeAuthorizedAddressAtIndexData = erc20Proxy.removeAuthorizedAddressAtIndex.getABIEncodedTransactionData( authorized, erc20Index, diff --git a/contracts/multisig/test/multi_sig_with_time_lock.ts b/contracts/multisig/test/multi_sig_with_time_lock.ts index 9596271514..cd6c6b3571 100644 --- a/contracts/multisig/test/multi_sig_with_time_lock.ts +++ b/contracts/multisig/test/multi_sig_with_time_lock.ts @@ -241,13 +241,13 @@ describe('MultiSigWalletWithTimeLock', () => { multiSigWrapper = new MultiSigWrapper(multiSig, provider); }); - it('should throw when not called by wallet', async () => { + it('should revert when not called by wallet', async () => { return expectTransactionFailedWithoutReasonAsync( multiSig.changeTimeLock.sendTransactionAsync(SECONDS_TIME_LOCKED, { from: owners[0] }), ); }); - it('should throw without enough confirmations', async () => { + it('should revert without enough confirmations', async () => { const destination = multiSig.address; const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); const res = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); @@ -325,7 +325,7 @@ describe('MultiSigWalletWithTimeLock', () => { await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); }); - it('should throw if it has enough confirmations but is not past the time lock', async () => { + it('should revert if it has enough confirmations but is not past the time lock', async () => { return expectTransactionFailedAsync( multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), RevertReason.TimeLockIncomplete, diff --git a/contracts/utils/test/ownable.ts b/contracts/utils/test/ownable.ts index 6fc908e13a..e204a48d3e 100644 --- a/contracts/utils/test/ownable.ts +++ b/contracts/utils/test/ownable.ts @@ -30,7 +30,7 @@ describe('Ownable', () => { }); describe('onlyOwner', () => { - it('should throw if sender is not the owner', async () => { + it('should revert if sender is not the owner', async () => { const expectedError = new OwnableRevertErrors.OnlyOwnerError(nonOwner, owner); return expect(ownable.externalOnlyOwner.callAsync({ from: nonOwner })).to.revertWith(expectedError); }); diff --git a/contracts/utils/test/reentrancy_guard.ts b/contracts/utils/test/reentrancy_guard.ts index e2bf9c38f0..270c9eab84 100644 --- a/contracts/utils/test/reentrancy_guard.ts +++ b/contracts/utils/test/reentrancy_guard.ts @@ -28,7 +28,7 @@ describe('ReentrancyGuard', () => { }); describe('nonReentrant', () => { - it('should throw if reentrancy occurs', async () => { + it('should revert if reentrancy occurs', async () => { const expectedError = new ReentrancyGuardRevertErrors.IllegalReentrancyError(); return expect(guard.guarded.sendTransactionAsync(true)).to.revertWith(expectedError); }); diff --git a/contracts/utils/test/safe_math.ts b/contracts/utils/test/safe_math.ts index aa4f1f35bc..d273767434 100644 --- a/contracts/utils/test/safe_math.ts +++ b/contracts/utils/test/safe_math.ts @@ -76,7 +76,7 @@ describe('SafeMath', () => { expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); }); - it('should return zero if second argument is zero', async () => { + it('should revert if second argument is zero', async () => { const errMessage = 'VM Exception while processing transaction: invalid opcode'; return expect(safeMath.externalSafeDiv.callAsync(toBN(1), constants.ZERO_AMOUNT)).to.be.rejectedWith( errMessage, @@ -85,7 +85,7 @@ describe('SafeMath', () => { }); describe('_safeSub', () => { - it('should throw if the subtraction underflows', async () => { + it('should revert if the subtraction underflows', async () => { const a = toBN(0); const b = toBN(1); const expectedError = new SafeMathRevertErrors.SafeMathError( @@ -108,7 +108,7 @@ describe('SafeMath', () => { }); describe('_safeAdd', () => { - it('should throw if the addition overflows', async () => { + it('should revert if the addition overflows', async () => { const a = toBN('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); // The largest uint256 number const b = toBN(1); const expectedError = new SafeMathRevertErrors.SafeMathError(