diff options
-rw-r--r-- | src/contract_wrappers/exchange_wrapper.ts | 9 | ||||
-rw-r--r-- | test/exchange_wrapper_test.ts | 11 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 5473e2565..214a19df9 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -349,11 +349,10 @@ export class ExchangeWrapper extends ContractWrapper { orderFillOrKillRequestsSchema, ); const exchangeInstance = await this.getExchangeContractAsync(); - _.each(orderFillOrKillRequests, request => { - this.validateFillOrKillOrderAndThrowIfInvalidAsync(request.signedOrder, - exchangeInstance.address, - request.fillTakerAmount); - }); + for (const request of orderFillOrKillRequests) { + await this.validateFillOrKillOrderAndThrowIfInvalidAsync(request.signedOrder, exchangeInstance.address, + request.fillTakerAmount); + } const orderAddressesValuesAndTakerTokenFillAmounts = _.map(orderFillOrKillRequests, request => { return [ diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index f159de759..6a511e68d 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -531,6 +531,7 @@ describe('ExchangeWrapper', () => { let fillableAmount: BigNumber.BigNumber; let partialFillAmount: BigNumber.BigNumber; let signedOrder: SignedOrder; + let orderHash: string; before(() => { takerAddress = userAddresses[1]; const [makerToken, takerToken] = tokens; @@ -543,6 +544,7 @@ describe('ExchangeWrapper', () => { signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync( makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount, ); + orderHash = await zeroEx.getOrderHashHexAsync(signedOrder); }); describe('#getUnavailableTakerAmountAsync', () => { it ('should throw if passed an invalid orderHash', async () => { @@ -554,7 +556,6 @@ describe('ExchangeWrapper', () => { expect(unavailableValueT).to.be.bignumber.equal(0); }); it ('should return the unavailableValueT for a valid and partially filled orderHash', async () => { - const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder); const unavailableValueT = await zeroEx.exchange.getUnavailableTakerAmountAsync(orderHash); expect(unavailableValueT).to.be.bignumber.equal(partialFillAmount); }); @@ -569,7 +570,6 @@ describe('ExchangeWrapper', () => { expect(filledValueT).to.be.bignumber.equal(0); }); it ('should return the filledValueT for a valid and partially filled orderHash', async () => { - const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder); const filledValueT = await zeroEx.exchange.getFilledTakerAmountAsync(orderHash); expect(filledValueT).to.be.bignumber.equal(partialFillAmount); }); @@ -584,10 +584,15 @@ describe('ExchangeWrapper', () => { expect(cancelledValueT).to.be.bignumber.equal(0); }); it ('should return the cancelledValueT for a valid and partially filled orderHash', async () => { - const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder); const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHash); expect(cancelledValueT).to.be.bignumber.equal(0); }); + it ('should return the cancelledValueT for a valid and cancelled orderHash', async () => { + const cancelAmount = fillableAmount.minus(partialFillAmount); + await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmount); + const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHash); + expect(cancelledValueT).to.be.bignumber.equal(cancelAmount); + }); }); }); describe('#subscribeAsync', () => { |