From 448be396cba7265d6ea0d69c9388e32db25773e8 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 1 Jun 2017 14:52:25 +0200 Subject: Remove unnecessary checks --- test/exchange_wrapper_test.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index ca040ab28..548ef0c36 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -148,11 +148,6 @@ describe('ExchangeWrapper', () => { const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, networkId, maker, 5, addressBySymbol.MLN, 5, addressBySymbol.GNT); const fillAmount = new BigNumber(5); - expect(await zeroEx.token.getBalanceAsync(addressBySymbol.MLN, maker)).to.be.bignumber.greaterThan(5); - expect(await zeroEx.token.getBalanceAsync(addressBySymbol.MLN, taker)).to.be.bignumber.equal(0); - expect(await zeroEx.token.getBalanceAsync(addressBySymbol.GNT, taker)).to.be.bignumber.equal(5); - expect(await zeroEx.token.getProxyAllowanceAsync(addressBySymbol.MLN, maker)).to.be.bignumber.equal(5); - expect(await zeroEx.token.getProxyAllowanceAsync(addressBySymbol.GNT, taker)).to.be.bignumber.equal(5); zeroEx.setDefaultAccount(taker); await zeroEx.exchange.fillOrderAsync(signedOrder, fillAmount); expect(await zeroEx.token.getBalanceAsync(addressBySymbol.MLN, taker)).to.be.bignumber.equal(5); -- cgit v1.2.3 From ef7ac6ac2df34cc45bce461bbbf0e83be5187aed Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 1 Jun 2017 14:53:26 +0200 Subject: Rename order to order_factory --- test/exchange_wrapper_test.ts | 2 +- test/utils/order.ts | 38 -------------------------------------- test/utils/order_factory.ts | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 39 deletions(-) delete mode 100644 test/utils/order.ts create mode 100644 test/utils/order_factory.ts diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index 548ef0c36..352eb9e05 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -6,7 +6,7 @@ import promisify = require('es6-promisify'); import * as _ from 'lodash'; import {BlockchainLifecycle} from './utils/blockchain_lifecycle'; import * as BigNumber from 'bignumber.js'; -import {orderFactory} from './utils/order'; +import {orderFactory} from './utils/order_factory'; import {Token} from '../src/types'; import * as Web3 from 'web3'; import * as dirtyChai from 'dirty-chai'; diff --git a/test/utils/order.ts b/test/utils/order.ts deleted file mode 100644 index 8a7d8430e..000000000 --- a/test/utils/order.ts +++ /dev/null @@ -1,38 +0,0 @@ -import {SignedOrder, Token} from '../../src/types'; -import * as BigNumber from 'bignumber.js'; -import * as _ from 'lodash'; -import {ZeroEx} from '../../src/0x.js'; -import {constants} from './constants'; -import * as ExchangeArtifacts from '../../src/artifacts/Exchange.json'; - -export const orderFactory = { - async createSignedOrderAsync( - zeroEx: ZeroEx, - networkId: number, - maker: string, - makerTokenAmount: BigNumber.BigNumber|number, - makerTokenAddress: string, - takerTokenAmount: BigNumber.BigNumber|number, - takerTokenAddress: string): Promise { - // TODO refactor and check - const exchangeAddress: string = (ExchangeArtifacts as any).networks[networkId].address; - const INF_TIMESTAMP = 2524604400; - const order = { - maker, - taker: undefined, - makerFee: new BigNumber(0), - takerFee: new BigNumber(0), - makerTokenAmount: _.isNumber(makerTokenAmount) ? new BigNumber(makerTokenAmount) : makerTokenAmount, - takerTokenAmount: _.isNumber(takerTokenAmount) ? new BigNumber(takerTokenAmount) : takerTokenAmount, - makerTokenAddress, - takerTokenAddress, - salt: ZeroEx.generatePseudoRandomSalt(), - feeRecipient: constants.NULL_ADDRESS, - expirationUnixTimestampSec: new BigNumber(INF_TIMESTAMP), - }; - const orderHash = ZeroEx.getOrderHashHex(exchangeAddress, order); - const ecSignature = await zeroEx.signOrderHashAsync(orderHash); - const signedOrder: SignedOrder = _.assign(order, {ecSignature}); - return signedOrder; - } -} diff --git a/test/utils/order_factory.ts b/test/utils/order_factory.ts new file mode 100644 index 000000000..8a7d8430e --- /dev/null +++ b/test/utils/order_factory.ts @@ -0,0 +1,38 @@ +import {SignedOrder, Token} from '../../src/types'; +import * as BigNumber from 'bignumber.js'; +import * as _ from 'lodash'; +import {ZeroEx} from '../../src/0x.js'; +import {constants} from './constants'; +import * as ExchangeArtifacts from '../../src/artifacts/Exchange.json'; + +export const orderFactory = { + async createSignedOrderAsync( + zeroEx: ZeroEx, + networkId: number, + maker: string, + makerTokenAmount: BigNumber.BigNumber|number, + makerTokenAddress: string, + takerTokenAmount: BigNumber.BigNumber|number, + takerTokenAddress: string): Promise { + // TODO refactor and check + const exchangeAddress: string = (ExchangeArtifacts as any).networks[networkId].address; + const INF_TIMESTAMP = 2524604400; + const order = { + maker, + taker: undefined, + makerFee: new BigNumber(0), + takerFee: new BigNumber(0), + makerTokenAmount: _.isNumber(makerTokenAmount) ? new BigNumber(makerTokenAmount) : makerTokenAmount, + takerTokenAmount: _.isNumber(takerTokenAmount) ? new BigNumber(takerTokenAmount) : takerTokenAmount, + makerTokenAddress, + takerTokenAddress, + salt: ZeroEx.generatePseudoRandomSalt(), + feeRecipient: constants.NULL_ADDRESS, + expirationUnixTimestampSec: new BigNumber(INF_TIMESTAMP), + }; + const orderHash = ZeroEx.getOrderHashHex(exchangeAddress, order); + const ecSignature = await zeroEx.signOrderHashAsync(orderHash); + const signedOrder: SignedOrder = _.assign(order, {ecSignature}); + return signedOrder; + } +} -- cgit v1.2.3 From 75d0b69db294a58b8fdca330d4724ecf758d65f2 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 1 Jun 2017 14:57:34 +0200 Subject: Add taker parameter to createSignedOrder --- test/exchange_wrapper_test.ts | 6 ++++-- test/utils/order_factory.ts | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index 352eb9e05..b2fb1894b 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -128,7 +128,9 @@ describe('ExchangeWrapper', () => { }); describe('failed fills', () => { it('should throw when the fill amount is zero', async () => { - const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, networkId, userAddresses[0], + const maker = userAddresses[0]; + const taker = userAddresses[1]; + const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, networkId, maker, taker, 5, addressBySymbol.MLN, 5, addressBySymbol.GNT); const fillAmount = new BigNumber(0); expect(zeroEx.exchange.fillOrderAsync(signedOrder, fillAmount)) @@ -145,7 +147,7 @@ describe('ExchangeWrapper', () => { await setAllowance(maker, 5, addressBySymbol.MLN); await setBalance(taker, 5, addressBySymbol.GNT); await setAllowance(taker, 5, addressBySymbol.GNT); - const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, networkId, maker, + const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, networkId, maker, taker, 5, addressBySymbol.MLN, 5, addressBySymbol.GNT); const fillAmount = new BigNumber(5); zeroEx.setDefaultAccount(taker); diff --git a/test/utils/order_factory.ts b/test/utils/order_factory.ts index 8a7d8430e..e41e973ee 100644 --- a/test/utils/order_factory.ts +++ b/test/utils/order_factory.ts @@ -10,6 +10,7 @@ export const orderFactory = { zeroEx: ZeroEx, networkId: number, maker: string, + taker: string, makerTokenAmount: BigNumber.BigNumber|number, makerTokenAddress: string, takerTokenAmount: BigNumber.BigNumber|number, @@ -19,7 +20,7 @@ export const orderFactory = { const INF_TIMESTAMP = 2524604400; const order = { maker, - taker: undefined, + taker, makerFee: new BigNumber(0), takerFee: new BigNumber(0), makerTokenAmount: _.isNumber(makerTokenAmount) ? new BigNumber(makerTokenAmount) : makerTokenAmount, -- cgit v1.2.3