Change all instances of throw to revert in it tests

This commit is contained in:
Alex Towle 2019-08-01 15:10:06 -07:00
parent 77feaec444
commit 8c5c81fe70
15 changed files with 80 additions and 80 deletions

View File

@ -46,7 +46,7 @@ describe('Authorizable', () => {
await blockchainLifecycle.revertAsync(); await blockchainLifecycle.revertAsync();
}); });
describe('addAuthorizedAddress', () => { 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 expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner);
const tx = authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner }); const tx = authorizable.addAuthorizedAddress.sendTransactionAsync(notOwner, { from: notOwner });
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
@ -60,7 +60,7 @@ describe('Authorizable', () => {
const isAuthorized = await authorizable.authorized.callAsync(address); const isAuthorized = await authorizable.authorized.callAsync(address);
expect(isAuthorized).to.be.true(); 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( await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
address, address,
{ from: owner }, { from: owner },
@ -74,7 +74,7 @@ describe('Authorizable', () => {
}); });
describe('removeAuthorizedAddress', () => { describe('removeAuthorizedAddress', () => {
it('should throw if not called by owner', async () => { it('should revert if not called by owner', async () => {
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync( await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
address, address,
{ from: owner }, { from: owner },
@ -100,7 +100,7 @@ describe('Authorizable', () => {
expect(isAuthorized).to.be.false(); 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( return expectTransactionFailedAsync(
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, { authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
from: owner, from: owner,
@ -111,7 +111,7 @@ describe('Authorizable', () => {
}); });
describe('removeAuthorizedAddressAtIndex', () => { describe('removeAuthorizedAddressAtIndex', () => {
it('should throw if not called by owner', async () => { it('should revert if not called by owner', async () => {
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync( await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
address, address,
{ from: owner }, { from: owner },
@ -124,7 +124,7 @@ describe('Authorizable', () => {
}); });
return expect(tx).to.revertWith(expectedError); 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( await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(
address, address,
{ from: owner }, { from: owner },
@ -138,7 +138,7 @@ describe('Authorizable', () => {
RevertReason.IndexOutOfBounds, 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); const index = new BigNumber(0);
return expectTransactionFailedAsync( return expectTransactionFailedAsync(
authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, { authorizable.removeAuthorizedAddressAtIndex.sendTransactionAsync(address, index, {
@ -147,7 +147,7 @@ describe('Authorizable', () => {
RevertReason.TargetNotAuthorized, 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 address1 = address;
const address2 = notOwner; const address2 = notOwner;
await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync( await authorizable.addAuthorizedAddress.awaitTransactionSuccessAsync(

View File

@ -166,7 +166,7 @@ describe('ERC1155Token', () => {
]; ];
await erc1155Wrapper.assertBalancesAsync(tokenHolders, [tokenToTransfer], expectedFinalBalances); await erc1155Wrapper.assertBalancesAsync(tokenHolders, [tokenToTransfer], expectedFinalBalances);
}); });
it('should throw if transfer reverts', async () => { it('should revert if transfer reverts', async () => {
// setup test parameters // setup test parameters
const tokenToTransfer = fungibleToken; const tokenToTransfer = fungibleToken;
const valueToTransfer = spenderInitialFungibleBalance.plus(1); const valueToTransfer = spenderInitialFungibleBalance.plus(1);
@ -187,7 +187,7 @@ describe('ERC1155Token', () => {
); );
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
}); });
it('should throw if callback reverts', async () => { it('should revert if callback reverts', async () => {
// setup test parameters // setup test parameters
const tokenToTransfer = fungibleToken; const tokenToTransfer = fungibleToken;
const valueToTransfer = fungibleValueToTransfer; const valueToTransfer = fungibleValueToTransfer;
@ -342,7 +342,7 @@ describe('ERC1155Token', () => {
]; ];
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances); await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances);
}); });
it('should throw if transfer reverts', async () => { it('should revert if transfer reverts', async () => {
// setup test parameters // setup test parameters
const tokensToTransfer = [fungibleToken]; const tokensToTransfer = [fungibleToken];
const valuesToTransfer = [spenderInitialFungibleBalance.plus(1)]; const valuesToTransfer = [spenderInitialFungibleBalance.plus(1)];
@ -363,7 +363,7 @@ describe('ERC1155Token', () => {
); );
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
}); });
it('should throw if callback reverts', async () => { it('should revert if callback reverts', async () => {
// setup test parameters // setup test parameters
const tokensToTransfer = [fungibleToken]; const tokensToTransfer = [fungibleToken];
const valuesToTransfer = [fungibleValueToTransfer]; const valuesToTransfer = [fungibleValueToTransfer];
@ -417,7 +417,7 @@ describe('ERC1155Token', () => {
]; ];
await erc1155Wrapper.assertBalancesAsync(tokenHolders, [tokenToTransfer], expectedFinalBalances); 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 // check approval not set
const isApprovedForAllCheck = await erc1155Wrapper.isApprovedForAllAsync(spender, delegatedSpender); const isApprovedForAllCheck = await erc1155Wrapper.isApprovedForAllAsync(spender, delegatedSpender);
expect(isApprovedForAllCheck).to.be.false(); expect(isApprovedForAllCheck).to.be.false();
@ -470,7 +470,7 @@ describe('ERC1155Token', () => {
]; ];
await erc1155Wrapper.assertBalancesAsync(tokenHolders, tokensToTransfer, expectedFinalBalances); 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 // check approval not set
const isApprovedForAllCheck = await erc1155Wrapper.isApprovedForAllAsync(spender, delegatedSpender); const isApprovedForAllCheck = await erc1155Wrapper.isApprovedForAllAsync(spender, delegatedSpender);
expect(isApprovedForAllCheck).to.be.false(); expect(isApprovedForAllCheck).to.be.false();

View File

@ -54,7 +54,7 @@ describe('UnlimitedAllowanceToken', () => {
await blockchainLifecycle.revertAsync(); await blockchainLifecycle.revertAsync();
}); });
describe('transfer', () => { 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 ownerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = ownerBalance.plus(1); const amountToTransfer = ownerBalance.plus(1);
return expectContractCallFailedAsync( return expectContractCallFailedAsync(
@ -89,7 +89,7 @@ describe('UnlimitedAllowanceToken', () => {
}); });
describe('transferFrom', () => { 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 ownerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = ownerBalance.plus(1); const amountToTransfer = ownerBalance.plus(1);
await web3Wrapper.awaitTransactionSuccessAsync( 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 ownerBalance = await token.balanceOf.callAsync(owner);
const amountToTransfer = ownerBalance; const amountToTransfer = ownerBalance;

View File

@ -45,7 +45,7 @@ describe('EtherToken', () => {
await blockchainLifecycle.revertAsync(); await blockchainLifecycle.revertAsync();
}); });
describe('deposit', () => { 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 initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
const ethToDeposit = initEthBalance.plus(1); const ethToDeposit = initEthBalance.plus(1);
@ -74,7 +74,7 @@ describe('EtherToken', () => {
}); });
describe('withdraw', () => { 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 initEthTokenBalance = await etherToken.balanceOf.callAsync(account);
const ethTokensToWithdraw = initEthTokenBalance.plus(1); const ethTokensToWithdraw = initEthTokenBalance.plus(1);

View File

@ -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(); signedOrder = await orderFactory.newSignedOrderAsync();
const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder); const orderHashHex = orderHashUtils.getOrderHashHex(signedOrder);
await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress); await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress);
@ -423,7 +423,7 @@ describe('Exchange core', () => {
).to.be.bignumber.equal(signedOrder.takerFee); ).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(); const currentTimestamp = await getLatestBlockTimestampAsync();
signedOrder = await orderFactory.newSignedOrderAsync({ signedOrder = await orderFactory.newSignedOrderAsync({
expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10), expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10),
@ -742,14 +742,14 @@ describe('Exchange core', () => {
signedOrder = await orderFactory.newSignedOrderAsync(); 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 orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const expectedError = new ExchangeRevertErrors.InvalidMakerError(orderHash, takerAddress); const expectedError = new ExchangeRevertErrors.InvalidMakerError(orderHash, takerAddress);
const tx = exchangeWrapper.cancelOrderAsync(signedOrder, takerAddress); const tx = exchangeWrapper.cancelOrderAsync(signedOrder, takerAddress);
return expect(tx).to.revertWith(expectedError); 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({ signedOrder = await orderFactory.newSignedOrderAsync({
makerAssetAmount: new BigNumber(0), makerAssetAmount: new BigNumber(0),
}); });
@ -762,7 +762,7 @@ describe('Exchange core', () => {
return expect(tx).to.revertWith(expectedError); 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({ signedOrder = await orderFactory.newSignedOrderAsync({
takerAssetAmount: new BigNumber(0), takerAssetAmount: new BigNumber(0),
}); });
@ -800,7 +800,7 @@ describe('Exchange core', () => {
expect(orderHashUtils.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash); 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); await exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress);
const orderHash = orderHashUtils.getOrderHashHex(signedOrder); const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHash, OrderStatus.Cancelled); const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHash, OrderStatus.Cancelled);
@ -808,7 +808,7 @@ describe('Exchange core', () => {
return expect(tx).to.revertWith(expectedError); 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(); const currentTimestamp = await getLatestBlockTimestampAsync();
signedOrder = await orderFactory.newSignedOrderAsync({ signedOrder = await orderFactory.newSignedOrderAsync({
expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10), expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10),
@ -819,7 +819,7 @@ describe('Exchange core', () => {
return expect(tx).to.revertWith(expectedError); 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({ signedOrder = await orderFactory.newSignedOrderAsync({
makerAssetAmount: new BigNumber(1001), makerAssetAmount: new BigNumber(1001),
takerAssetAmount: new BigNumber(3), takerAssetAmount: new BigNumber(3),
@ -936,7 +936,7 @@ describe('Exchange core', () => {
}); });
describe('Testing Exchange of ERC721 Tokens', () => { 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 // Construct Exchange parameters
const makerAssetId = erc721TakerAssetIds[0]; const makerAssetId = erc721TakerAssetIds[0];
const takerAssetId = erc721TakerAssetIds[1]; const takerAssetId = erc721TakerAssetIds[1];
@ -963,7 +963,7 @@ describe('Exchange core', () => {
return expect(tx).to.revertWith(expectedError); 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 // Construct Exchange parameters
const makerAssetId = erc721MakerAssetIds[0]; const makerAssetId = erc721MakerAssetIds[0];
const takerAssetId = erc721MakerAssetIds[1]; const takerAssetId = erc721MakerAssetIds[1];
@ -990,7 +990,7 @@ describe('Exchange core', () => {
return expect(tx).to.revertWith(expectedError); 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 // Construct Exchange parameters
const makerAssetId = erc721MakerAssetIds[0]; const makerAssetId = erc721MakerAssetIds[0];
const takerAssetId = erc721TakerAssetIds[0]; const takerAssetId = erc721TakerAssetIds[0];
@ -1017,7 +1017,7 @@ describe('Exchange core', () => {
return expect(tx).to.revertWith(expectedError); 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 // Construct Exchange parameters
const makerAssetId = erc721MakerAssetIds[0]; const makerAssetId = erc721MakerAssetIds[0];
const takerAssetId = erc721TakerAssetIds[0]; const takerAssetId = erc721TakerAssetIds[0];
@ -1044,7 +1044,7 @@ describe('Exchange core', () => {
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
}); });
it('should throw on partial fill', async () => { it('should revert on partial fill', async () => {
// Construct Exchange parameters // Construct Exchange parameters
const makerAssetId = erc721MakerAssetIds[0]; const makerAssetId = erc721MakerAssetIds[0];
signedOrder = await orderFactory.newSignedOrderAsync({ signedOrder = await orderFactory.newSignedOrderAsync({

View File

@ -114,7 +114,7 @@ describe('AssetProxyDispatcher', () => {
expect(proxyAddress).to.be.equal(erc721Proxy.address); 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 // Initial registration
await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, { await assetProxyDispatcher.registerAssetProxy.awaitTransactionSuccessAsync(erc20Proxy.address, {
from: owner, from: owner,
@ -134,7 +134,7 @@ describe('AssetProxyDispatcher', () => {
return expect(tx).to.revertWith(expectedError); 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 expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwner, owner);
const tx = assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, { const tx = assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, {
from: notOwner, from: notOwner,
@ -250,7 +250,7 @@ describe('AssetProxyDispatcher', () => {
expect(newBalances).to.deep.equal(erc20Balances); 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 // Construct metadata for ERC20 proxy
const encodedAssetData = assetDataUtils.encodeERC20AssetData(erc20TokenA.address); const encodedAssetData = assetDataUtils.encodeERC20AssetData(erc20TokenA.address);
// Perform a transfer from makerAddress to takerAddress // Perform a transfer from makerAddress to takerAddress

View File

@ -175,7 +175,7 @@ describe('FillOrder Tests', () => {
await fillOrderCombinatorialUtils.testFillOrderScenarioSuccessAsync(fillScenario); 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 = { const fillScenario = {
...defaultFillScenario, ...defaultFillScenario,
orderScenario: { orderScenario: {
@ -186,7 +186,7 @@ describe('FillOrder Tests', () => {
await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario);
}); });
it('should throw if makerAssetAmount is 0', async () => { it('should revert if makerAssetAmount is 0', async () => {
const fillScenario = { const fillScenario = {
...defaultFillScenario, ...defaultFillScenario,
orderScenario: { orderScenario: {
@ -198,7 +198,7 @@ describe('FillOrder Tests', () => {
await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario);
}); });
it('should throw if takerAssetAmount is 0', async () => { it('should revert if takerAssetAmount is 0', async () => {
const fillScenario = { const fillScenario = {
...defaultFillScenario, ...defaultFillScenario,
orderScenario: { orderScenario: {
@ -210,7 +210,7 @@ describe('FillOrder Tests', () => {
await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario);
}); });
it('should throw if takerAssetFillAmount is 0', async () => { it('should revert if takerAssetFillAmount is 0', async () => {
const fillScenario = { const fillScenario = {
...defaultFillScenario, ...defaultFillScenario,
takerAssetFillAmountScenario: TakerAssetFillAmountScenario.Zero, takerAssetFillAmountScenario: TakerAssetFillAmountScenario.Zero,
@ -218,7 +218,7 @@ describe('FillOrder Tests', () => {
await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario);
}); });
it('should throw if an order is expired', async () => { it('should revert if an order is expired', async () => {
const fillScenario = { const fillScenario = {
...defaultFillScenario, ...defaultFillScenario,
orderScenario: { orderScenario: {
@ -331,7 +331,7 @@ describe('FillOrder Tests', () => {
await fillOrderCombinatorialUtils.testFillOrderScenarioSuccessAsync(fillScenario); 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 = { const fillScenario = {
...defaultFillScenario, ...defaultFillScenario,
makerStateScenario: { makerStateScenario: {
@ -342,7 +342,7 @@ describe('FillOrder Tests', () => {
await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); 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 = { const fillScenario = {
...defaultFillScenario, ...defaultFillScenario,
takerStateScenario: { takerStateScenario: {
@ -353,7 +353,7 @@ describe('FillOrder Tests', () => {
await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); 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 = { const fillScenario = {
...defaultFillScenario, ...defaultFillScenario,
makerStateScenario: { makerStateScenario: {
@ -364,7 +364,7 @@ describe('FillOrder Tests', () => {
await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); 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 = { const fillScenario = {
...defaultFillScenario, ...defaultFillScenario,
takerStateScenario: { takerStateScenario: {
@ -375,7 +375,7 @@ describe('FillOrder Tests', () => {
await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); 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 = { const fillScenario = {
...defaultFillScenario, ...defaultFillScenario,
makerStateScenario: { makerStateScenario: {
@ -386,7 +386,7 @@ describe('FillOrder Tests', () => {
await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); 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 = { const fillScenario = {
...defaultFillScenario, ...defaultFillScenario,
takerStateScenario: { takerStateScenario: {
@ -397,7 +397,7 @@ describe('FillOrder Tests', () => {
await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); 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 = { const fillScenario = {
...defaultFillScenario, ...defaultFillScenario,
makerStateScenario: { makerStateScenario: {
@ -408,7 +408,7 @@ describe('FillOrder Tests', () => {
await fillOrderCombinatorialUtils.testFillOrderScenarioFailureAsync(fillScenario); 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 = { const fillScenario = {
...defaultFillScenario, ...defaultFillScenario,
takerStateScenario: { takerStateScenario: {

View File

@ -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 // Create orders to match
const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18),
@ -1305,7 +1305,7 @@ describe('matchOrders', () => {
return expect(tx).to.revertWith(expectedError); 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 // Create orders to match
const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18),
@ -1324,7 +1324,7 @@ describe('matchOrders', () => {
return expect(tx).to.revertWith(expectedError); 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 // Create orders to match
const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18),
@ -1342,7 +1342,7 @@ describe('matchOrders', () => {
return expect(tx).to.revertWith(expectedError); 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 // Create orders to match
const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18),
@ -1373,7 +1373,7 @@ describe('matchOrders', () => {
return expect(tx).to.revertWith(expectedError); 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 // Create orders to match
const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress), 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 // Create orders to match
const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18),
@ -2435,7 +2435,7 @@ describe('matchOrders', () => {
return expect(tx).to.revertWith(expectedError); 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 // Create orders to match
const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18),
@ -2454,7 +2454,7 @@ describe('matchOrders', () => {
return expect(tx).to.revertWith(expectedError); 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 // Create orders to match
const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18),
@ -2472,7 +2472,7 @@ describe('matchOrders', () => {
return expect(tx).to.revertWith(expectedError); 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 // Create orders to match
const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18), makerAssetAmount: Web3Wrapper.toBaseUnitAmount(5, 18),
@ -2503,7 +2503,7 @@ describe('matchOrders', () => {
return expect(tx).to.revertWith(expectedError); 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 // Create orders to match
const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({ const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress), takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),

View File

@ -495,7 +495,7 @@ describe('MixinSignatureValidator', () => {
return expect(tx).to.revertWith(expectedError); 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 // Set approval of signature validator to false
await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync(
validatorWallet.address, validatorWallet.address,
@ -702,7 +702,7 @@ describe('MixinSignatureValidator', () => {
return expect(tx).to.revertWith(expectedError); 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 // Set approval of signature validator to false
await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync( await signatureValidator.setSignatureValidatorApproval.awaitTransactionSuccessAsync(
validatorWallet.address, validatorWallet.address,

View File

@ -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 currentTimestamp = await getLatestBlockTimestampAsync();
const signedOrder = await orderFactory.newSignedOrderAsync({ const signedOrder = await orderFactory.newSignedOrderAsync({
expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10), expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10),
@ -245,7 +245,7 @@ describe('Exchange wrappers', () => {
return expect(tx).to.revertWith(expectedError); 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(); const signedOrder = await orderFactory.newSignedOrderAsync();
await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, {
@ -815,7 +815,7 @@ describe('Exchange wrappers', () => {
expect(newBalances).to.be.deep.equal(erc20Balances); 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[] = []; const takerAssetFillAmounts: BigNumber[] = [];
_.forEach(signedOrders, signedOrder => { _.forEach(signedOrders, signedOrder => {
const takerAssetFillAmount = signedOrder.takerAssetAmount.div(2); const takerAssetFillAmount = signedOrder.takerAssetAmount.div(2);
@ -922,7 +922,7 @@ describe('Exchange wrappers', () => {
expect(newBalances).to.be.deep.equal(erc20Balances); 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 makerAssetAddress = erc20TokenA.address;
const takerAssetAddress = erc20TokenB.address; const takerAssetAddress = erc20TokenB.address;
@ -1132,7 +1132,7 @@ describe('Exchange wrappers', () => {
expect(newBalances).to.be.deep.equal(erc20Balances); 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 = [ signedOrders = [
await orderFactory.newSignedOrderAsync(), await orderFactory.newSignedOrderAsync(),
await orderFactory.newSignedOrderAsync({ await orderFactory.newSignedOrderAsync({
@ -1510,7 +1510,7 @@ describe('Exchange wrappers', () => {
expect(newBalances).to.be.deep.equal(erc20Balances); 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 = [ signedOrders = [
await orderFactory.newSignedOrderAsync(), await orderFactory.newSignedOrderAsync(),
await orderFactory.newSignedOrderAsync({ await orderFactory.newSignedOrderAsync({

View File

@ -115,7 +115,7 @@ describe('AssetProxyOwner', () => {
expect(isErc20ProxyRegistered).to.equal(true); expect(isErc20ProxyRegistered).to.equal(true);
expect(isErc721ProxyRegistered).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]; const assetProxyContractAddresses = [erc20Proxy.address, constants.NULL_ADDRESS];
return expectContractCreationFailedAsync( return expectContractCreationFailedAsync(
(AssetProxyOwnerContract.deployFrom0xArtifactAsync( (AssetProxyOwnerContract.deployFrom0xArtifactAsync(
@ -158,7 +158,7 @@ describe('AssetProxyOwner', () => {
}); });
describe('registerAssetProxy', () => { describe('registerAssetProxy', () => {
it('should throw if not called by multisig', async () => { it('should revert if not called by multisig', async () => {
const isRegistered = true; const isRegistered = true;
return expectTransactionFailedWithoutReasonAsync( return expectTransactionFailedWithoutReasonAsync(
testAssetProxyOwner.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, isRegistered, { testAssetProxyOwner.registerAssetProxy.sendTransactionAsync(erc20Proxy.address, isRegistered, {
@ -338,7 +338,7 @@ describe('AssetProxyOwner', () => {
}); });
describe('executeRemoveAuthorizedAddressAtIndex', () => { describe('executeRemoveAuthorizedAddressAtIndex', () => {
it('should throw without the required confirmations', async () => { it('should revert without the required confirmations', async () => {
const removeAuthorizedAddressAtIndexData = erc20Proxy.removeAuthorizedAddressAtIndex.getABIEncodedTransactionData( const removeAuthorizedAddressAtIndexData = erc20Proxy.removeAuthorizedAddressAtIndex.getABIEncodedTransactionData(
authorized, authorized,
erc20Index, 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( const removeAuthorizedAddressAtIndexData = erc721Proxy.removeAuthorizedAddressAtIndex.getABIEncodedTransactionData(
authorized, authorized,
erc721Index, 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 newAuthorized = owners[1];
const addAuthorizedAddressData = erc20Proxy.addAuthorizedAddress.getABIEncodedTransactionData( const addAuthorizedAddressData = erc20Proxy.addAuthorizedAddress.getABIEncodedTransactionData(
newAuthorized, newAuthorized,
@ -468,7 +468,7 @@ describe('AssetProxyOwner', () => {
expect(isAuthorizedAfter).to.equal(false); expect(isAuthorizedAfter).to.equal(false);
}); });
it('should throw if already executed', async () => { it('should revert if already executed', async () => {
const removeAuthorizedAddressAtIndexData = erc20Proxy.removeAuthorizedAddressAtIndex.getABIEncodedTransactionData( const removeAuthorizedAddressAtIndexData = erc20Proxy.removeAuthorizedAddressAtIndex.getABIEncodedTransactionData(
authorized, authorized,
erc20Index, erc20Index,

View File

@ -241,13 +241,13 @@ describe('MultiSigWalletWithTimeLock', () => {
multiSigWrapper = new MultiSigWrapper(multiSig, provider); 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( return expectTransactionFailedWithoutReasonAsync(
multiSig.changeTimeLock.sendTransactionAsync(SECONDS_TIME_LOCKED, { from: owners[0] }), 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 destination = multiSig.address;
const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED); const changeTimeLockData = multiSig.changeTimeLock.getABIEncodedTransactionData(SECONDS_TIME_LOCKED);
const res = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]); const res = await multiSigWrapper.submitTransactionAsync(destination, changeTimeLockData, owners[0]);
@ -325,7 +325,7 @@ describe('MultiSigWalletWithTimeLock', () => {
await multiSigWrapper.confirmTransactionAsync(txId, owners[1]); 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( return expectTransactionFailedAsync(
multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }), multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }),
RevertReason.TimeLockIncomplete, RevertReason.TimeLockIncomplete,

View File

@ -30,7 +30,7 @@ describe('Ownable', () => {
}); });
describe('onlyOwner', () => { 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); const expectedError = new OwnableRevertErrors.OnlyOwnerError(nonOwner, owner);
return expect(ownable.externalOnlyOwner.callAsync({ from: nonOwner })).to.revertWith(expectedError); return expect(ownable.externalOnlyOwner.callAsync({ from: nonOwner })).to.revertWith(expectedError);
}); });

View File

@ -28,7 +28,7 @@ describe('ReentrancyGuard', () => {
}); });
describe('nonReentrant', () => { describe('nonReentrant', () => {
it('should throw if reentrancy occurs', async () => { it('should revert if reentrancy occurs', async () => {
const expectedError = new ReentrancyGuardRevertErrors.IllegalReentrancyError(); const expectedError = new ReentrancyGuardRevertErrors.IllegalReentrancyError();
return expect(guard.guarded.sendTransactionAsync(true)).to.revertWith(expectedError); return expect(guard.guarded.sendTransactionAsync(true)).to.revertWith(expectedError);
}); });

View File

@ -76,7 +76,7 @@ describe('SafeMath', () => {
expect(result).bignumber.to.be.eq(constants.ZERO_AMOUNT); 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'; const errMessage = 'VM Exception while processing transaction: invalid opcode';
return expect(safeMath.externalSafeDiv.callAsync(toBN(1), constants.ZERO_AMOUNT)).to.be.rejectedWith( return expect(safeMath.externalSafeDiv.callAsync(toBN(1), constants.ZERO_AMOUNT)).to.be.rejectedWith(
errMessage, errMessage,
@ -85,7 +85,7 @@ describe('SafeMath', () => {
}); });
describe('_safeSub', () => { describe('_safeSub', () => {
it('should throw if the subtraction underflows', async () => { it('should revert if the subtraction underflows', async () => {
const a = toBN(0); const a = toBN(0);
const b = toBN(1); const b = toBN(1);
const expectedError = new SafeMathRevertErrors.SafeMathError( const expectedError = new SafeMathRevertErrors.SafeMathError(
@ -108,7 +108,7 @@ describe('SafeMath', () => {
}); });
describe('_safeAdd', () => { 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 a = toBN('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'); // The largest uint256 number
const b = toBN(1); const b = toBN(1);
const expectedError = new SafeMathRevertErrors.SafeMathError( const expectedError = new SafeMathRevertErrors.SafeMathError(