diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-06-27 09:38:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-27 09:38:30 +0800 |
commit | 73c36fe2d20c0e477458e6c07b837b08f8d424c6 (patch) | |
tree | 1cb07f3bdc14812cd4eb67610a93f8e6c2670d16 /packages/contracts/test/exchange | |
parent | 744e6e60c51b2bfd081920b58a73e566113fee0e (diff) | |
parent | ec3e9efdaaf35f408f708b359f648d6addbfa1f2 (diff) | |
download | dexon-sol-tools-73c36fe2d20c0e477458e6c07b837b08f8d424c6.tar dexon-sol-tools-73c36fe2d20c0e477458e6c07b837b08f8d424c6.tar.gz dexon-sol-tools-73c36fe2d20c0e477458e6c07b837b08f8d424c6.tar.bz2 dexon-sol-tools-73c36fe2d20c0e477458e6c07b837b08f8d424c6.tar.lz dexon-sol-tools-73c36fe2d20c0e477458e6c07b837b08f8d424c6.tar.xz dexon-sol-tools-73c36fe2d20c0e477458e6c07b837b08f8d424c6.tar.zst dexon-sol-tools-73c36fe2d20c0e477458e6c07b837b08f8d424c6.zip |
Merge pull request #773 from 0xProject/feature/contracts/abi-calldata-proxy
Optimize transfer
Diffstat (limited to 'packages/contracts/test/exchange')
-rw-r--r-- | packages/contracts/test/exchange/core.ts | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts index 99d2bc157..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, ); }); @@ -817,7 +816,7 @@ describe('Exchange core', () => { const takerAssetFillAmount = signedOrder.takerAssetAmount; return expectRevertReasonOrAlwaysFailingTransactionAsync( exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }), - RevertReason.TransferFailed, + RevertReason.InvalidAmount, ); }); @@ -840,7 +839,7 @@ describe('Exchange core', () => { const takerAssetFillAmount = signedOrder.takerAssetAmount; return expectRevertReasonOrAlwaysFailingTransactionAsync( exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }), - RevertReason.TransferFailed, + RevertReason.InvalidAmount, ); }); @@ -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]; |