From 595656d3fc06a221274eb6bee89e7ba6e4e8ae61 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 31 May 2017 20:08:28 +0200 Subject: [PATCH 1/8] Move isValidOrderHash to utils and implement assert.isValidOrderHash --- src/0x.js.ts | 8 ++++---- src/utils/assert.ts | 4 ++++ src/utils/utils.ts | 4 ++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/0x.js.ts b/src/0x.js.ts index d231c579e7..ac00d3b42a 100644 --- a/src/0x.js.ts +++ b/src/0x.js.ts @@ -102,10 +102,10 @@ export class ZeroEx { return salt; } /** Checks if order hash is valid */ - public static isValidOrderHash(orderHash: string): boolean { - assert.isString('orderHash', orderHash); - const isValid = /^0x[0-9A-F]{64}$/i.test(orderHash); - return isValid; + public static isValidOrderHash(orderHashHex: string): boolean { + assert.isString('orderHashHex', orderHashHex); + const isValidOrderHash = utils.isValidOrderHash(orderHashHex); + return isValidOrderHash; } /** * A unit amount is defined as the amount of a token above the specified decimal places (integer part). diff --git a/src/utils/assert.ts b/src/utils/assert.ts index 1baf572d14..0088b3b134 100644 --- a/src/utils/assert.ts +++ b/src/utils/assert.ts @@ -2,6 +2,7 @@ import * as _ from 'lodash'; import * as BigNumber from 'bignumber.js'; import * as Web3 from 'web3'; import {SchemaValidator} from './schema_validator'; +import {utils} from './utils'; const HEX_REGEX = /^0x[0-9A-F]*$/i; @@ -27,6 +28,9 @@ export const assert = { isNumber(variableName: string, value: number): void { this.assert(_.isFinite(value), this.typeAssertionMessage(variableName, 'number', value)); }, + isValidOrderHash(variableName: string, value: string): void { + this.assert(utils.isValidOrderHash(value), this.typeAssertionMessage(variableName, 'orderHash', value)); + }, doesConformToSchema(variableName: string, value: object, schema: Schema): void { const schemaValidator = new SchemaValidator(); const validationResult = schemaValidator.validate(value, schema); diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 336eaf7bbb..e6840a6249 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -18,4 +18,8 @@ export const utils = { isParityNode(nodeVersion: string): boolean { return _.includes(nodeVersion, 'Parity'); }, + isValidOrderHash(orderHashHex: string) { + const isValid = /^0x[0-9A-F]{64}$/i.test(orderHashHex); + return isValid; + }, }; From 52c3330487c9cb1e3fc78cda752717b684deca38 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 31 May 2017 20:10:09 +0200 Subject: [PATCH 2/8] Implement getUnavailableTakerAmountAsync, getFilledTakerAmountAsync and getCanceledTakerAmountAsync --- src/contract_wrappers/exchange_wrapper.ts | 33 +++++++++++++++++++++++ src/types.ts | 9 +++++++ 2 files changed, 42 insertions(+) diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 3f6eb0daba..74303cf82a 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -1,4 +1,5 @@ import * as _ from 'lodash'; +import * as BigNumber from 'bignumber.js'; import {Web3Wrapper} from '../web3_wrapper'; import {ECSignature, ZeroExError, ExchangeContract} from '../types'; import {assert} from '../utils/assert'; @@ -37,6 +38,38 @@ export class ExchangeWrapper extends ContractWrapper { ); return isValidSignature; } + /** + * Returns the unavailable takerAmount of an order. Unavailable amount is defined as the total + * amount that has been filled or cancelled. The remaining takerAmount can be calculated by + * subtracting the unavailable amount from the total order takerAmount. + */ + public async getUnavailableTakerAmountAsync(orderHashHex: string): Promise { + assert.isValidOrderHash('orderHashHex', orderHashHex); + + const exchangeContract = await this.getExchangeContractAsync(); + const unavailableAmountInBaseUnits = await exchangeContract.getUnavailableValueT.call(orderHashHex); + return unavailableAmountInBaseUnits; + } + /** + * Retrieve the takerAmount of an order that has already been filled. + */ + public async getFilledTakerAmountAsync(orderHashHex: string): Promise { + assert.isValidOrderHash('orderHashHex', orderHashHex); + + const exchangeContract = await this.getExchangeContractAsync(); + const fillAmountInBaseUnits = await exchangeContract.filled.call(orderHashHex); + return fillAmountInBaseUnits; + } + /** + * Retrieve the takerAmount of an order that has been cancelled. + */ + public async getCanceledTakerAmountAsync(orderHashHex: string): Promise { + assert.isValidOrderHash('orderHashHex', orderHashHex); + + const exchangeContract = await this.getExchangeContractAsync(); + const cancelledAmountInBaseUnits = await exchangeContract.cancelled.call(orderHashHex); + return cancelledAmountInBaseUnits; + } private async getExchangeContractAsync(): Promise { if (!_.isUndefined(this.exchangeContractIfExists)) { return this.exchangeContractIfExists; diff --git a/src/types.ts b/src/types.ts index 3619c800f7..25338a5317 100644 --- a/src/types.ts +++ b/src/types.ts @@ -29,6 +29,15 @@ export interface ECSignature { export interface ExchangeContract { isValidSignature: any; + getUnavailableValueT: { + call: (orderHash: string) => BigNumber.BigNumber; + }; + filled: { + call: (orderHash: string) => BigNumber.BigNumber; + }; + cancelled: { + call: (orderHash: string) => BigNumber.BigNumber; + }; } export interface TokenContract { From aade6891e834dda7e80d76740882facdb45bc014 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 1 Jun 2017 18:35:23 +0200 Subject: [PATCH 3/8] fix tslint error --- src/contract_wrappers/exchange_wrapper.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 0822ef875f..6f6380bb8c 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -153,7 +153,8 @@ export class ExchangeWrapper extends ContractWrapper { ); this.throwErrorLogsAsErrors(response.logs); } - private async validateFillOrderAsync(signedOrder: SignedOrder, fillAmount: BigNumber.BigNumber, senderAddress: string) { + private async validateFillOrderAsync(signedOrder: SignedOrder, fillAmount: BigNumber.BigNumber, + senderAddress: string) { if (fillAmount.eq(0)) { throw new Error(FillOrderValidationErrs.FILL_AMOUNT_IS_ZERO); } From 293ce6f4b2e495589ae3675eb293fb9948f22dbb Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 2 Jun 2017 09:39:05 +0200 Subject: [PATCH 4/8] Always wrap BigNumbers returned by web3 with our own version and add comment --- src/contract_wrappers/exchange_wrapper.ts | 12 +++++++++--- src/contract_wrappers/token_wrapper.ts | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 8b20d2b4d4..2894c5a9fd 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -70,7 +70,9 @@ export class ExchangeWrapper extends ContractWrapper { assert.isValidOrderHash('orderHashHex', orderHashHex); const exchangeContract = await this.getExchangeContractAsync(); - const unavailableAmountInBaseUnits = await exchangeContract.getUnavailableValueT.call(orderHashHex); + let unavailableAmountInBaseUnits = await exchangeContract.getUnavailableValueT.call(orderHashHex); + // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber + unavailableAmountInBaseUnits = new BigNumber(unavailableAmountInBaseUnits); return unavailableAmountInBaseUnits; } /** @@ -80,7 +82,9 @@ export class ExchangeWrapper extends ContractWrapper { assert.isValidOrderHash('orderHashHex', orderHashHex); const exchangeContract = await this.getExchangeContractAsync(); - const fillAmountInBaseUnits = await exchangeContract.filled.call(orderHashHex); + let fillAmountInBaseUnits = await exchangeContract.filled.call(orderHashHex); + // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber + fillAmountInBaseUnits = new BigNumber(fillAmountInBaseUnits); return fillAmountInBaseUnits; } /** @@ -90,7 +94,9 @@ export class ExchangeWrapper extends ContractWrapper { assert.isValidOrderHash('orderHashHex', orderHashHex); const exchangeContract = await this.getExchangeContractAsync(); - const cancelledAmountInBaseUnits = await exchangeContract.cancelled.call(orderHashHex); + let cancelledAmountInBaseUnits = await exchangeContract.cancelled.call(orderHashHex); + // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber + cancelledAmountInBaseUnits = new BigNumber(cancelledAmountInBaseUnits); return cancelledAmountInBaseUnits; } /** diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index cedbfbdae3..69bcc90242 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -28,8 +28,7 @@ export class TokenWrapper extends ContractWrapper { const tokenContract = await this.getTokenContractAsync(tokenAddress); let balance = await tokenContract.balanceOf.call(ownerAddress); - // The BigNumber instance returned by Web3 is of a much older version then our own, we therefore - // should always re-instantiate the returned BigNumber after retrieval. + // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber balance = new BigNumber(balance); return balance; } @@ -44,6 +43,7 @@ export class TokenWrapper extends ContractWrapper { const tokenContract = await this.getTokenContractAsync(tokenAddress); const proxyAddress = await this.getProxyAddressAsync(); let allowanceInBaseUnits = await tokenContract.allowance.call(ownerAddress, proxyAddress); + // Wrap BigNumbers returned from web3 with our own (later) version of BigNumber allowanceInBaseUnits = new BigNumber(allowanceInBaseUnits); return allowanceInBaseUnits; } From 707a5f55eb919b3460ae4ee7d58b9a0eaa56a07c Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 2 Jun 2017 09:43:03 +0200 Subject: [PATCH 5/8] Write tests for getUnavailableTakerAmountAsync, getFilledTakerAmountAsync and getCanceledTakerAmountAsync --- src/0x.js.ts | 12 +++-- test/exchange_wrapper_test.ts | 85 +++++++++++++++++++++++++++++++---- test/utils/fill_scenarios.ts | 20 +++++++++ 3 files changed, 106 insertions(+), 11 deletions(-) diff --git a/src/0x.js.ts b/src/0x.js.ts index 2bced325fb..b42d5dee15 100644 --- a/src/0x.js.ts +++ b/src/0x.js.ts @@ -17,7 +17,7 @@ import {TokenRegistryWrapper} from './contract_wrappers/token_registry_wrapper'; import {ecSignatureSchema} from './schemas/ec_signature_schema'; import {TokenWrapper} from './contract_wrappers/token_wrapper'; import {SolidityTypes, ECSignature, ZeroExError} from './types'; -import {Order} from './types'; +import {Order, SignedOrder} from './types'; import {orderSchema} from './schemas/order_schemas'; import * as ExchangeArtifacts from './artifacts/Exchange.json'; @@ -116,17 +116,23 @@ export class ZeroEx { this.tokenRegistry.invalidateContractInstance(); this.token.invalidateContractInstances(); } - /** * Sets default account for sending transactions. */ public setTransactionSenderAccount(account: string): void { this.web3Wrapper.setDefaultAccount(account); } + /** + * Get the default account set for sending transactions. + */ + public async getTransactionSenderAccountAsync(): Promise { + const senderAccount = await this.web3Wrapper.getSenderAddressOrThrowAsync(); + return senderAccount; + } /** * Computes the orderHash given the order parameters and returns it as a hex encoded string. */ - public async getOrderHashHexAsync(order: Order): Promise { + public async getOrderHashHexAsync(order: Order|SignedOrder): Promise { const exchangeContractAddr = await this.getExchangeAddressAsync(); assert.doesConformToSchema('order', SchemaValidator.convertToJSONSchemaCompatibleObject(order as object), diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index 77c78470b7..519442d9f0 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -18,14 +18,20 @@ chai.use(ChaiBigNumber()); const expect = chai.expect; const blockchainLifecycle = new BlockchainLifecycle(); +const NON_EXISTENT_ORDER_HASH = '0x79370342234e7acd6bbeac335bd3bb1d368383294b64b8160a00f4060e4d3777'; + describe('ExchangeWrapper', () => { let zeroEx: ZeroEx; let userAddresses: string[]; let web3: Web3; + let tokens: Token[]; + let fillScenarios: FillScenarios; before(async () => { web3 = web3Factory.create(); zeroEx = new ZeroEx(web3); userAddresses = await promisify(web3.eth.getAccounts)(); + tokens = await zeroEx.tokenRegistry.getTokensAsync(); + fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens); }); beforeEach(async () => { await blockchainLifecycle.startAsync(); @@ -104,24 +110,16 @@ describe('ExchangeWrapper', () => { }); }); describe('#fillOrderAsync', () => { - let tokens: Token[]; let makerTokenAddress: string; let takerTokenAddress: string; - let fillScenarios: FillScenarios; let takerAddress: string; const fillTakerAmountInBaseUnits = new BigNumber(5); - const addressBySymbol: {[symbol: string]: string} = {}; const shouldCheckTransfer = false; before('fetch tokens', async () => { takerAddress = userAddresses[1]; - tokens = await zeroEx.tokenRegistry.getTokensAsync(); - _.forEach(tokens, token => { - addressBySymbol[token.symbol] = token.address; - }); const [makerToken, takerToken] = tokens; makerTokenAddress = makerToken.address; takerTokenAddress = takerToken.address; - fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens); }); afterEach('reset default account', () => { zeroEx.setTransactionSenderAccount(userAddresses[0]); @@ -185,4 +183,75 @@ describe('ExchangeWrapper', () => { }); }); }); + describe('tests that require partially filled order', () => { + let makerTokenAddress: string; + let takerTokenAddress: string; + let takerAddress: string; + before(() => { + takerAddress = userAddresses[1]; + const [makerToken, takerToken] = tokens; + makerTokenAddress = makerToken.address; + takerTokenAddress = takerToken.address; + }); + describe('#getUnavailableTakerAmountAsync', () => { + it ('should throw if passed an invalid orderHash', async () => { + const invalidOrderHashHex = '0x123'; + expect(zeroEx.exchange.getUnavailableTakerAmountAsync(invalidOrderHashHex)).to.be.rejected(); + }); + it ('should return zero if passed a valid but non-existent orderHash', async () => { + const unavailableValueT = await zeroEx.exchange.getUnavailableTakerAmountAsync(NON_EXISTENT_ORDER_HASH); + expect(unavailableValueT).to.be.bignumber.equal(0); + }); + it ('should return the unavailableValueT for a valid and partially filled orderHash', async () => { + const fillableAmount = new BigNumber(5); + const partialFillAmount = new BigNumber(2); + const signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync( + makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount, + ); + const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder); + const unavailableValueT = await zeroEx.exchange.getUnavailableTakerAmountAsync(orderHash); + expect(unavailableValueT).to.be.bignumber.equal(partialFillAmount); + }); + }); + describe('#getFilledTakerAmountAsync', () => { + it ('should throw if passed an invalid orderHash', async () => { + const invalidOrderHashHex = '0x123'; + expect(zeroEx.exchange.getFilledTakerAmountAsync(invalidOrderHashHex)).to.be.rejected(); + }); + it ('should return zero if passed a valid but non-existent orderHash', async () => { + const filledValueT = await zeroEx.exchange.getFilledTakerAmountAsync(NON_EXISTENT_ORDER_HASH); + expect(filledValueT).to.be.bignumber.equal(0); + }); + it ('should return the filledValueT for a valid and partially filled orderHash', async () => { + const fillableAmount = new BigNumber(5); + const partialFillAmount = new BigNumber(2); + const signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync( + makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount, + ); + const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder); + const filledValueT = await zeroEx.exchange.getFilledTakerAmountAsync(orderHash); + expect(filledValueT).to.be.bignumber.equal(partialFillAmount); + }); + }); + describe('#getCanceledTakerAmountAsync', () => { + it ('should throw if passed an invalid orderHash', async () => { + const invalidOrderHashHex = '0x123'; + expect(zeroEx.exchange.getCanceledTakerAmountAsync(invalidOrderHashHex)).to.be.rejected(); + }); + it ('should return zero if passed a valid but non-existent orderHash', async () => { + const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync(NON_EXISTENT_ORDER_HASH); + expect(cancelledValueT).to.be.bignumber.equal(0); + }); + it ('should return the cancelledValueT for a valid and partially filled orderHash', async () => { + const fillableAmount = new BigNumber(5); + const partialFillAmount = new BigNumber(2); + const signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync( + makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount, + ); + const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder); + const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHash); + expect(cancelledValueT).to.be.bignumber.equal(0); + }); + }); + }); }); diff --git a/test/utils/fill_scenarios.ts b/test/utils/fill_scenarios.ts index ac233ad50b..36656b4555 100644 --- a/test/utils/fill_scenarios.ts +++ b/test/utils/fill_scenarios.ts @@ -26,4 +26,24 @@ export class FillScenarios { expirationUnixTimestampSec); return signedOrder; } + public async createPartiallyFilledSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string, + takerAddress: string, fillableAmount: BigNumber.BigNumber, + partialFillAmount: BigNumber.BigNumber) { + const prevSenderAccount = await this.zeroEx.getTransactionSenderAccountAsync(); + const [makerAddress] = this.userAddresses; + await this.zeroEx.token.setProxyAllowanceAsync(makerTokenAddress, makerAddress, fillableAmount); + await this.zeroEx.token.transferAsync(takerTokenAddress, makerAddress, takerAddress, fillableAmount); + await this.zeroEx.token.setProxyAllowanceAsync(takerTokenAddress, takerAddress, fillableAmount); + + const signedOrder = await orderFactory.createSignedOrderAsync(this.zeroEx, makerAddress, + takerAddress, fillableAmount, makerTokenAddress, fillableAmount, takerTokenAddress); + + this.zeroEx.setTransactionSenderAccount(takerAddress); + const shouldCheckTransfer = false; + await this.zeroEx.exchange.fillOrderAsync(signedOrder, partialFillAmount, shouldCheckTransfer); + + // Re-set sender account so as to avoid introducing side-effects + this.zeroEx.setTransactionSenderAccount(prevSenderAccount); + return signedOrder; + } } From 2cf5208f85bca11a507a5b0e2202f5f6eb531753 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 2 Jun 2017 09:49:50 +0200 Subject: [PATCH 6/8] Add comment about the isString assertion lest the next developer tries to use a stricter assertion (i.e isHexString) which we intentionally did not do --- src/0x.js.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/0x.js.ts b/src/0x.js.ts index b42d5dee15..666fd00c62 100644 --- a/src/0x.js.ts +++ b/src/0x.js.ts @@ -71,6 +71,8 @@ export class ZeroEx { } /** Checks if order hash is valid */ public static isValidOrderHash(orderHashHex: string): boolean { + // Since this method can be called to check if any arbitrary string conforms to an orderHash's + // format, we only assert that we were indeed passed a string. assert.isString('orderHashHex', orderHashHex); const isValidOrderHash = utils.isValidOrderHash(orderHashHex); return isValidOrderHash; From 114b5ea0fe78b9b9b5b4fc46e13b21e45f77a628 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 2 Jun 2017 09:59:10 +0200 Subject: [PATCH 7/8] improve comment --- src/0x.js.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/0x.js.ts b/src/0x.js.ts index 666fd00c62..0e9d71586c 100644 --- a/src/0x.js.ts +++ b/src/0x.js.ts @@ -69,7 +69,10 @@ export class ZeroEx { const salt = randomNumber.times(factor).round(); return salt; } - /** Checks if order hash is valid */ + /** + * Checks if the supplied hex encoded order hash is valid. + * Note: Valid means it has the expected format, not that an order with the orderHash exists. + */ public static isValidOrderHash(orderHashHex: string): boolean { // Since this method can be called to check if any arbitrary string conforms to an orderHash's // format, we only assert that we were indeed passed a string. From 03bc3f08cd0d1c51dc9eb4441a3415e131b72c95 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 2 Jun 2017 10:02:19 +0200 Subject: [PATCH 8/8] Simplify tests --- test/exchange_wrapper_test.ts | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index 519442d9f0..d50a5f0310 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -10,7 +10,7 @@ import {web3Factory} from './utils/web3_factory'; import {ZeroEx} from '../src/0x.js'; import {BlockchainLifecycle} from './utils/blockchain_lifecycle'; import {orderFactory} from './utils/order_factory'; -import {FillOrderValidationErrs, Token} from '../src/types'; +import {FillOrderValidationErrs, Token, SignedOrder} from '../src/types'; import {FillScenarios} from './utils/fill_scenarios'; chai.use(dirtyChai); @@ -187,12 +187,22 @@ describe('ExchangeWrapper', () => { let makerTokenAddress: string; let takerTokenAddress: string; let takerAddress: string; + let fillableAmount: BigNumber.BigNumber; + let partialFillAmount: BigNumber.BigNumber; + let signedOrder: SignedOrder; before(() => { takerAddress = userAddresses[1]; const [makerToken, takerToken] = tokens; makerTokenAddress = makerToken.address; takerTokenAddress = takerToken.address; }); + beforeEach(async () => { + fillableAmount = new BigNumber(5); + partialFillAmount = new BigNumber(2); + signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync( + makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount, + ); + }); describe('#getUnavailableTakerAmountAsync', () => { it ('should throw if passed an invalid orderHash', async () => { const invalidOrderHashHex = '0x123'; @@ -203,11 +213,6 @@ describe('ExchangeWrapper', () => { expect(unavailableValueT).to.be.bignumber.equal(0); }); it ('should return the unavailableValueT for a valid and partially filled orderHash', async () => { - const fillableAmount = new BigNumber(5); - const partialFillAmount = new BigNumber(2); - const signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync( - makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount, - ); const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder); const unavailableValueT = await zeroEx.exchange.getUnavailableTakerAmountAsync(orderHash); expect(unavailableValueT).to.be.bignumber.equal(partialFillAmount); @@ -223,11 +228,6 @@ describe('ExchangeWrapper', () => { expect(filledValueT).to.be.bignumber.equal(0); }); it ('should return the filledValueT for a valid and partially filled orderHash', async () => { - const fillableAmount = new BigNumber(5); - const partialFillAmount = new BigNumber(2); - const signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync( - makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount, - ); const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder); const filledValueT = await zeroEx.exchange.getFilledTakerAmountAsync(orderHash); expect(filledValueT).to.be.bignumber.equal(partialFillAmount); @@ -243,11 +243,6 @@ describe('ExchangeWrapper', () => { expect(cancelledValueT).to.be.bignumber.equal(0); }); it ('should return the cancelledValueT for a valid and partially filled orderHash', async () => { - const fillableAmount = new BigNumber(5); - const partialFillAmount = new BigNumber(2); - const signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync( - makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount, - ); const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder); const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHash); expect(cancelledValueT).to.be.bignumber.equal(0);