From 8d76d74a1713dcec140c8d43f9ea7612b5cc38f1 Mon Sep 17 00:00:00 2001 From: Ara Kevonian <=> Date: Mon, 9 Apr 2018 04:49:05 -0700 Subject: Implement `zeroEx.exchange.getOrderStateAsync` --- packages/0x.js/test/exchange_wrapper_test.ts | 39 +++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'packages/0x.js/test') diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts index cfc390bae..b6eaa2591 100644 --- a/packages/0x.js/test/exchange_wrapper_test.ts +++ b/packages/0x.js/test/exchange_wrapper_test.ts @@ -14,7 +14,7 @@ import { LogCancelContractEventArgs, LogFillContractEventArgs, OrderCancellationRequest, - OrderFillRequest, + OrderFillRequest, OrderState, OrderStateInvalid, SignedOrder, Token, ZeroEx, @@ -1156,4 +1156,41 @@ describe('ExchangeWrapper', () => { expect(args.maker).to.be.equal(differentMakerAddress); }); }); + describe('#getOrderState', () => { + let maker: string; + let taker: string; + let makerToken: Token; + let takerToken: Token; + let signedOrder: SignedOrder; + let orderState: OrderState; + const fillableAmount = ZeroEx.toBaseUnitAmount(new BigNumber(5), constants.ZRX_DECIMALS); + before(async () => { + [, maker, taker] = userAddresses; + tokens = await zeroEx.tokenRegistry.getTokensAsync(); + [makerToken, takerToken] = tokenUtils.getDummyTokens(); + }); + it('should report orderStateValid when order is fillable', async () => { + signedOrder = await fillScenarios.createFillableSignedOrderAsync( + makerToken.address, + takerToken.address, + maker, + taker, + fillableAmount, + ); + orderState = await zeroEx.exchange.getOrderStateAsync(signedOrder); + expect(orderState.isValid).to.be.true(); + }); + it('should report orderStateInvalid when maker allowance set to 0', async () => { + signedOrder = await fillScenarios.createFillableSignedOrderAsync( + makerToken.address, + takerToken.address, + maker, + taker, + fillableAmount, + ); + await zeroEx.token.setProxyAllowanceAsync(makerToken.address, maker, new BigNumber(0)); + orderState = await zeroEx.exchange.getOrderStateAsync(signedOrder); + expect(orderState.isValid).to.be.false(); + }); + }); }); // tslint:disable:max-file-line-count -- cgit v1.2.3 From c80b42712a9fc73c05c32cd3d3396a6a02a7969f Mon Sep 17 00:00:00 2001 From: Ara Kevonian <=> Date: Mon, 9 Apr 2018 07:05:46 -0700 Subject: Lint/Prettify --- packages/0x.js/test/exchange_wrapper_test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'packages/0x.js/test') diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts index b6eaa2591..dd55d06a2 100644 --- a/packages/0x.js/test/exchange_wrapper_test.ts +++ b/packages/0x.js/test/exchange_wrapper_test.ts @@ -14,7 +14,8 @@ import { LogCancelContractEventArgs, LogFillContractEventArgs, OrderCancellationRequest, - OrderFillRequest, OrderState, OrderStateInvalid, + OrderFillRequest, + OrderState, SignedOrder, Token, ZeroEx, @@ -1156,7 +1157,7 @@ describe('ExchangeWrapper', () => { expect(args.maker).to.be.equal(differentMakerAddress); }); }); - describe('#getOrderState', () => { + describe('#getOrderStateAsync', () => { let maker: string; let taker: string; let makerToken: Token; -- cgit v1.2.3