diff options
author | Fabio Berger <me@fabioberger.com> | 2018-04-24 15:51:32 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-04-24 15:51:32 +0800 |
commit | b24b98a36557729acdc87aee3dabb4ff40f27d51 (patch) | |
tree | a98ddb2dfa620406152f5ae812263f3698641fd6 /packages/contracts/test/exchange/core.ts | |
parent | 432b064601776d4daacfc2415c3da41c91a24d27 (diff) | |
parent | fd041e2997dd10eeb5a50f413775e247176a8432 (diff) | |
download | dexon-sol-tools-b24b98a36557729acdc87aee3dabb4ff40f27d51.tar.gz dexon-sol-tools-b24b98a36557729acdc87aee3dabb4ff40f27d51.tar.zst dexon-sol-tools-b24b98a36557729acdc87aee3dabb4ff40f27d51.zip |
merge v2-prototype
Diffstat (limited to 'packages/contracts/test/exchange/core.ts')
-rw-r--r-- | packages/contracts/test/exchange/core.ts | 116 |
1 files changed, 61 insertions, 55 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts index 4d462826a..13dbcef88 100644 --- a/packages/contracts/test/exchange/core.ts +++ b/packages/contracts/test/exchange/core.ts @@ -27,7 +27,6 @@ import { AssetProxyId, ContractName, ERC20BalancesByOwner, - ERC721BalancesByOwner, ExchangeContractErrs, SignedOrder, } from '../../src/utils/types'; @@ -47,7 +46,7 @@ describe('Exchange core', () => { let erc20TokenA: DummyERC20TokenContract; let erc20TokenB: DummyERC20TokenContract; - let zrx: DummyERC20TokenContract; + let zrxToken: DummyERC20TokenContract; let erc721Token: DummyERC721TokenContract; let exchange: ExchangeContract; let erc20Proxy: ERC20ProxyContract; @@ -75,19 +74,20 @@ describe('Exchange core', () => { erc20Wrapper = new ERC20Wrapper(deployer, provider, usedAddresses, owner); erc721Wrapper = new ERC721Wrapper(deployer, provider, usedAddresses, owner); - [erc20TokenA, erc20TokenB, zrx] = await erc20Wrapper.deployDummyERC20TokensAsync(); - erc20Proxy = await erc20Wrapper.deployERC20ProxyAsync(); + [erc20TokenA, erc20TokenB, zrxToken] = await erc20Wrapper.deployDummyTokensAsync(); + erc20Proxy = await erc20Wrapper.deployProxyAsync(); await erc20Wrapper.setBalancesAndAllowancesAsync(); - [erc721Token] = await erc721Wrapper.deployDummyERC721TokensAsync(); - erc721Proxy = await erc721Wrapper.deployERC721ProxyAsync(); + [erc721Token] = await erc721Wrapper.deployDummyTokensAsync(); + erc721Proxy = await erc721Wrapper.deployProxyAsync(); await erc721Wrapper.setBalancesAndAllowancesAsync(); const erc721Balances = await erc721Wrapper.getBalancesAsync(); erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address]; erc721TakerAssetIds = erc721Balances[takerAddress][erc721Token.address]; const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [ - assetProxyUtils.encodeERC20ProxyData(zrx.address), + assetProxyDispatcher.address, + assetProxyUtils.encodeERC20ProxyData(zrxToken.address), ]); exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider); zeroEx = new ZeroEx(provider, { @@ -205,8 +205,8 @@ describe('Exchange core', () => { expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount), ); - expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[makerAddress][zrx.address].minus(makerFeePaid), + expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[makerAddress][zrxToken.address].minus(makerFeePaid), ); expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount), @@ -214,11 +214,11 @@ describe('Exchange core', () => { expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount), ); - expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[takerAddress][zrx.address].minus(takerFeePaid), + expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[takerAddress][zrxToken.address].minus(takerFeePaid), ); - expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrx.address].add(makerFeePaid.add(takerFeePaid)), + expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)), ); }); @@ -258,8 +258,8 @@ describe('Exchange core', () => { expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount), ); - expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[makerAddress][zrx.address].minus(makerFeePaid), + expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[makerAddress][zrxToken.address].minus(makerFeePaid), ); expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount), @@ -267,11 +267,11 @@ describe('Exchange core', () => { expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount), ); - expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[takerAddress][zrx.address].minus(takerFeePaid), + expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[takerAddress][zrxToken.address].minus(takerFeePaid), ); - expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrx.address].add(makerFeePaid.add(takerFeePaid)), + expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)), ); }); @@ -311,8 +311,8 @@ describe('Exchange core', () => { expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount), ); - expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[makerAddress][zrx.address].minus(makerFeePaid), + expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[makerAddress][zrxToken.address].minus(makerFeePaid), ); expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount), @@ -320,11 +320,11 @@ describe('Exchange core', () => { expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount), ); - expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[takerAddress][zrx.address].minus(takerFeePaid), + expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[takerAddress][zrxToken.address].minus(takerFeePaid), ); - expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrx.address].add(makerFeePaid.add(takerFeePaid)), + expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)), ); }); @@ -366,8 +366,8 @@ describe('Exchange core', () => { expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( erc20Balances[makerAddress][defaultTakerAssetAddress].add(takerAssetFillAmount), ); - expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[makerAddress][zrx.address].minus(makerFeePaid), + expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[makerAddress][zrxToken.address].minus(makerFeePaid), ); expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount), @@ -375,11 +375,11 @@ describe('Exchange core', () => { expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( erc20Balances[takerAddress][defaultMakerAssetAddress].add(makerAssetFilledAmount), ); - expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[takerAddress][zrx.address].minus(takerFeePaid), + expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[takerAddress][zrxToken.address].minus(takerFeePaid), ); - expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrx.address].add(makerFeePaid.add(takerFeePaid)), + expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFeePaid.add(takerFeePaid)), ); }); @@ -402,8 +402,8 @@ describe('Exchange core', () => { expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( erc20Balances[makerAddress][defaultTakerAssetAddress].add(signedOrder.takerAssetAmount), ); - expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[makerAddress][zrx.address].minus(signedOrder.makerFee), + expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[makerAddress][zrxToken.address].minus(signedOrder.makerFee), ); expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( erc20Balances[takerAddress][defaultTakerAssetAddress].minus(signedOrder.takerAssetAmount), @@ -411,11 +411,13 @@ describe('Exchange core', () => { expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( erc20Balances[takerAddress][defaultMakerAssetAddress].add(signedOrder.makerAssetAmount), ); - expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[takerAddress][zrx.address].minus(signedOrder.takerFee), + expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[takerAddress][zrxToken.address].minus(signedOrder.takerFee), ); - expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrx.address].add(signedOrder.makerFee.add(signedOrder.takerFee)), + expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[feeRecipientAddress][zrxToken.address].add( + signedOrder.makerFee.add(signedOrder.takerFee), + ), ); }); @@ -717,8 +719,8 @@ describe('Exchange core', () => { expect(newBalances[makerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( erc20Balances[makerAddress][defaultTakerAssetAddress].add(fillTakerAssetAmount), ); - expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[makerAddress][zrx.address].minus(makerFee), + expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[makerAddress][zrxToken.address].minus(makerFee), ); expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( erc20Balances[takerAddress][defaultTakerAssetAddress].minus(fillTakerAssetAmount), @@ -726,11 +728,11 @@ describe('Exchange core', () => { expect(newBalances[takerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( erc20Balances[takerAddress][defaultMakerAssetAddress].add(fillMakerAssetAmount), ); - expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[takerAddress][zrx.address].minus(takerFee), + expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[takerAddress][zrxToken.address].minus(takerFee), ); - expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrx.address].add(makerFee.add(takerFee)), + expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[feeRecipientAddress][zrxToken.address].add(makerFee.add(takerFee)), ); }); }); @@ -898,14 +900,16 @@ describe('Exchange core', () => { expect(newBalances[takerAddress][defaultTakerAssetAddress]).to.be.bignumber.equal( erc20Balances[takerAddress][defaultTakerAssetAddress].minus(takerAssetFillAmount), ); - expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[makerAddress][zrx.address].minus(signedOrder.makerFee), + expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[makerAddress][zrxToken.address].minus(signedOrder.makerFee), ); - expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[takerAddress][zrx.address].minus(signedOrder.takerFee), + expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[takerAddress][zrxToken.address].minus(signedOrder.takerFee), ); - expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrx.address].add(signedOrder.makerFee.add(signedOrder.takerFee)), + expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[feeRecipientAddress][zrxToken.address].add( + signedOrder.makerFee.add(signedOrder.takerFee), + ), ); }); @@ -936,14 +940,16 @@ describe('Exchange core', () => { expect(newBalances[makerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal( erc20Balances[makerAddress][defaultMakerAssetAddress].minus(signedOrder.makerAssetAmount), ); - expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[makerAddress][zrx.address].minus(signedOrder.makerFee), + expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[makerAddress][zrxToken.address].minus(signedOrder.makerFee), ); - expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[takerAddress][zrx.address].minus(signedOrder.takerFee), + expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[takerAddress][zrxToken.address].minus(signedOrder.takerFee), ); - expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal( - erc20Balances[feeRecipientAddress][zrx.address].add(signedOrder.makerFee.add(signedOrder.takerFee)), + expect(newBalances[feeRecipientAddress][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[feeRecipientAddress][zrxToken.address].add( + signedOrder.makerFee.add(signedOrder.takerFee), + ), ); }); }); |