diff options
author | Fabio Berger <me@fabioberger.com> | 2018-04-17 22:09:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-17 22:09:05 +0800 |
commit | bf4873e519762c6e13bb68c7a6757cc1ec25eb77 (patch) | |
tree | 2723d1e1eb7a3cf63fcb40a9d5a7d55abd808418 /packages/0x.js/test | |
parent | 7a8edb5018acaf7aaf49ebefd8b3afec713a19eb (diff) | |
parent | 8fc1b38ff20cf1b528070ecc824b4696d93a2e0f (diff) | |
download | dexon-0x-contracts-bf4873e519762c6e13bb68c7a6757cc1ec25eb77.tar dexon-0x-contracts-bf4873e519762c6e13bb68c7a6757cc1ec25eb77.tar.gz dexon-0x-contracts-bf4873e519762c6e13bb68c7a6757cc1ec25eb77.tar.bz2 dexon-0x-contracts-bf4873e519762c6e13bb68c7a6757cc1ec25eb77.tar.lz dexon-0x-contracts-bf4873e519762c6e13bb68c7a6757cc1ec25eb77.tar.xz dexon-0x-contracts-bf4873e519762c6e13bb68c7a6757cc1ec25eb77.tar.zst dexon-0x-contracts-bf4873e519762c6e13bb68c7a6757cc1ec25eb77.zip |
Merge pull request #510 from avonian/development
Implement `zeroEx.exchange.getOrderStateAsync`
Diffstat (limited to 'packages/0x.js/test')
-rw-r--r-- | packages/0x.js/test/exchange_wrapper_test.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts index cd74af5a1..65f4e8251 100644 --- a/packages/0x.js/test/exchange_wrapper_test.ts +++ b/packages/0x.js/test/exchange_wrapper_test.ts @@ -14,6 +14,7 @@ import { LogFillContractEventArgs, OrderCancellationRequest, OrderFillRequest, + OrderState, SignedOrder, Token, ZeroEx, @@ -1154,4 +1155,41 @@ describe('ExchangeWrapper', () => { expect(args.maker).to.be.equal(differentMakerAddress); }); }); + describe('#getOrderStateAsync', () => { + 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 |