aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/exchange/core.ts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-04-23 08:25:28 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-24 01:50:09 +0800
commit432b064601776d4daacfc2415c3da41c91a24d27 (patch)
tree40e4e240dbd3e7a5441d3d2c5a52f3a64b2a8ac6 /packages/contracts/test/exchange/core.ts
parenta8a0a5cbfb7299cd22181c8713e1da6dec412dae (diff)
downloaddexon-sol-tools-432b064601776d4daacfc2415c3da41c91a24d27.tar.gz
dexon-sol-tools-432b064601776d4daacfc2415c3da41c91a24d27.tar.zst
dexon-sol-tools-432b064601776d4daacfc2415c3da41c91a24d27.zip
Fix tests
Diffstat (limited to 'packages/contracts/test/exchange/core.ts')
-rw-r--r--packages/contracts/test/exchange/core.ts69
1 files changed, 9 insertions, 60 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 9065c5e3f..4d462826a 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -5,7 +5,6 @@ import * as chai from 'chai';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
-import { AssetProxyDispatcherContract } from '../../src/contract_wrappers/generated/asset_proxy_dispatcher';
import { DummyERC20TokenContract } from '../../src/contract_wrappers/generated/dummy_e_r_c20_token';
import { DummyERC721TokenContract } from '../../src/contract_wrappers/generated/dummy_e_r_c721_token';
import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c20_proxy';
@@ -51,7 +50,6 @@ describe('Exchange core', () => {
let zrx: DummyERC20TokenContract;
let erc721Token: DummyERC721TokenContract;
let exchange: ExchangeContract;
- let assetProxyDispatcher: AssetProxyDispatcherContract;
let erc20Proxy: ERC20ProxyContract;
let erc721Proxy: ERC721ProxyContract;
@@ -88,44 +86,24 @@ describe('Exchange core', () => {
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
erc721TakerAssetIds = erc721Balances[takerAddress][erc721Token.address];
- const assetProxyDispatcherInstance = await deployer.deployAsync(ContractName.AssetProxyDispatcher);
- assetProxyDispatcher = new AssetProxyDispatcherContract(
- assetProxyDispatcherInstance.abi,
- assetProxyDispatcherInstance.address,
- provider,
- );
- const prevERC20ProxyAddress = ZeroEx.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevERC20ProxyAddress,
- { from: owner },
- );
- const prevERC721ProxyAddress = ZeroEx.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC721,
- erc721Proxy.address,
- prevERC721ProxyAddress,
- { from: owner },
- );
- await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
- from: owner,
- });
- await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
- from: owner,
- });
-
const exchangeInstance = await deployer.deployAsync(ContractName.Exchange, [
- assetProxyDispatcher.address,
assetProxyUtils.encodeERC20ProxyData(zrx.address),
]);
exchange = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider);
- await assetProxyDispatcher.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner });
zeroEx = new ZeroEx(provider, {
exchangeContractAddress: exchange.address,
networkId: constants.TESTRPC_NETWORK_ID,
});
exchangeWrapper = new ExchangeWrapper(exchange, zeroEx);
+ await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
+ await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner);
+
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ });
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ });
defaultMakerAssetAddress = erc20TokenA.address;
defaultTakerAssetAddress = erc20TokenB.address;
@@ -467,35 +445,6 @@ describe('Exchange core', () => {
expect(orderUtils.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash);
});
- it('should log 1 event with the correct arguments when order has no feeRecipient', async () => {
- signedOrder = orderFactory.newSignedOrder({
- feeRecipientAddress: ZeroEx.NULL_ADDRESS,
- });
- const divisor = 2;
- const res = await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, {
- takerAssetFillAmount: signedOrder.takerAssetAmount.div(divisor),
- });
- expect(res.logs).to.have.length(1);
-
- const log = res.logs[0] as LogWithDecodedArgs<FillContractEventArgs>;
- const logArgs = log.args;
- const expectedFilledMakerAssetAmount = signedOrder.makerAssetAmount.div(divisor);
- const expectedFilledTakerAssetAmount = signedOrder.takerAssetAmount.div(divisor);
- const expectedFeeMPaid = new BigNumber(0);
- const expectedFeeTPaid = new BigNumber(0);
-
- expect(signedOrder.makerAddress).to.be.equal(logArgs.makerAddress);
- expect(takerAddress).to.be.equal(logArgs.takerAddress);
- expect(signedOrder.feeRecipientAddress).to.be.equal(logArgs.feeRecipientAddress);
- expect(signedOrder.makerAssetData).to.be.equal(logArgs.makerAssetData);
- expect(signedOrder.takerAssetData).to.be.equal(logArgs.takerAssetData);
- expect(expectedFilledMakerAssetAmount).to.be.bignumber.equal(logArgs.makerAssetFilledAmount);
- expect(expectedFilledTakerAssetAmount).to.be.bignumber.equal(logArgs.takerAssetFilledAmount);
- expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.makerFeePaid);
- expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.takerFeePaid);
- expect(orderUtils.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash);
- });
-
it('should throw when taker is specified and order is claimed by other', async () => {
signedOrder = orderFactory.newSignedOrder({
takerAddress: feeRecipientAddress,