From b6d8dcb6e11cfe8da6854371029fe1af3f6a68de Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Tue, 26 Jun 2018 12:59:35 -0700 Subject: Make dispatchTransferFrom revert with reason from AssetProxy on failure --- packages/contracts/test/exchange/core.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/contracts/test/exchange/core.ts') diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts index 99d2bc157..59756fe9a 100644 --- a/packages/contracts/test/exchange/core.ts +++ b/packages/contracts/test/exchange/core.ts @@ -817,7 +817,7 @@ describe('Exchange core', () => { const takerAssetFillAmount = signedOrder.takerAssetAmount; return expectRevertReasonOrAlwaysFailingTransactionAsync( exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }), - RevertReason.TransferFailed, + RevertReason.InvalidAmount, ); }); @@ -840,7 +840,7 @@ describe('Exchange core', () => { const takerAssetFillAmount = signedOrder.takerAssetAmount; return expectRevertReasonOrAlwaysFailingTransactionAsync( exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }), - RevertReason.TransferFailed, + RevertReason.InvalidAmount, ); }); -- cgit From 7f233dcb15f897a4c7de29987e26143c9d192c01 Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Tue, 26 Jun 2018 17:34:43 -0700 Subject: Add more revert reasons to tests --- packages/contracts/test/exchange/core.ts | 37 ++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'packages/contracts/test/exchange/core.ts') diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts index 59756fe9a..36f6fa8d3 100644 --- a/packages/contracts/test/exchange/core.ts +++ b/packages/contracts/test/exchange/core.ts @@ -17,10 +17,7 @@ import { FillContractEventArgs, } from '../../src/generated_contract_wrappers/exchange'; import { artifacts } from '../../src/utils/artifacts'; -import { - expectRevertOrAlwaysFailingTransactionAsync, - expectRevertReasonOrAlwaysFailingTransactionAsync, -} from '../../src/utils/assertions'; +import { expectRevertReasonOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions'; import { chaiSetup } from '../../src/utils/chai_setup'; import { constants } from '../../src/utils/constants'; import { ERC20Wrapper } from '../../src/utils/erc20_wrapper'; @@ -771,8 +768,9 @@ describe('Exchange core', () => { expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress); // Call Exchange const takerAssetFillAmount = signedOrder.takerAssetAmount; - return expectRevertOrAlwaysFailingTransactionAsync( + return expectRevertReasonOrAlwaysFailingTransactionAsync( exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }), + RevertReason.TransferFailed, ); }); @@ -793,8 +791,9 @@ describe('Exchange core', () => { expect(initialOwnerTakerAsset).to.be.bignumber.not.equal(takerAddress); // Call Exchange const takerAssetFillAmount = signedOrder.takerAssetAmount; - return expectRevertOrAlwaysFailingTransactionAsync( + return expectRevertReasonOrAlwaysFailingTransactionAsync( exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }), + RevertReason.TransferFailed, ); }); @@ -861,6 +860,32 @@ describe('Exchange core', () => { ); }); + it('should throw if assetData has a length < 132', async () => { + // Construct Exchange parameters + const makerAssetId = erc721MakerAssetIds[0]; + const takerAssetId = erc721TakerAssetIds[0]; + const makerAssetData = assetProxyUtils + .encodeERC721AssetData(erc721Token.address, makerAssetId) + .slice(0, -2); + signedOrder = orderFactory.newSignedOrder({ + makerAssetAmount: new BigNumber(1), + takerAssetAmount: new BigNumber(1), + makerAssetData, + takerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, takerAssetId), + }); + // Verify pre-conditions + const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId); + expect(initialOwnerMakerAsset).to.be.bignumber.equal(makerAddress); + const initialOwnerTakerAsset = await erc721Token.ownerOf.callAsync(takerAssetId); + expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress); + // Call Exchange + const takerAssetFillAmount = signedOrder.takerAssetAmount; + return expectRevertReasonOrAlwaysFailingTransactionAsync( + exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }), + RevertReason.LengthGreaterThan131Required, + ); + }); + it('should successfully fill order when makerAsset is ERC721 and takerAsset is ERC20', async () => { // Construct Exchange parameters const makerAssetId = erc721MakerAssetIds[0]; -- cgit