diff options
author | Jacob Evans <jacob@dekz.net> | 2017-11-16 05:20:39 +0800 |
---|---|---|
committer | Jacob Evans <jacob@dekz.net> | 2017-11-16 05:20:39 +0800 |
commit | c32938fa43ef7ab538465e5eeade924b23776e6c (patch) | |
tree | a156b236e580ea6839f7e430c8575cc5a85474fb /packages/0x.js/test | |
parent | 54c891a447fb5b47355e8f44a5b29bcc20bae1a1 (diff) | |
download | dexon-sol-tools-c32938fa43ef7ab538465e5eeade924b23776e6c.tar dexon-sol-tools-c32938fa43ef7ab538465e5eeade924b23776e6c.tar.gz dexon-sol-tools-c32938fa43ef7ab538465e5eeade924b23776e6c.tar.bz2 dexon-sol-tools-c32938fa43ef7ab538465e5eeade924b23776e6c.tar.lz dexon-sol-tools-c32938fa43ef7ab538465e5eeade924b23776e6c.tar.xz dexon-sol-tools-c32938fa43ef7ab538465e5eeade924b23776e6c.tar.zst dexon-sol-tools-c32938fa43ef7ab538465e5eeade924b23776e6c.zip |
Shortcut if everything satisfies in the non dependent use case
Diffstat (limited to 'packages/0x.js/test')
-rw-r--r-- | packages/0x.js/test/order_state_watcher_test.ts | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/packages/0x.js/test/order_state_watcher_test.ts b/packages/0x.js/test/order_state_watcher_test.ts index ac77ce4d7..fef7b5d13 100644 --- a/packages/0x.js/test/order_state_watcher_test.ts +++ b/packages/0x.js/test/order_state_watcher_test.ts @@ -335,8 +335,8 @@ describe('OrderStateWatcher', () => { const remainingFeeAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), 18); const transferFeeAmount = makerFee.sub(remainingFeeAmount); - const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18); - const transferTokenAmount = makerFee.sub(remainingFeeAmount); + const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(4), 18); + const transferTokenAmount = makerFee.sub(remainingTokenAmount); zeroEx.orderStateWatcher.addOrder(signedOrder); const callback = reportCallbackErrors(done)((orderState: OrderState) => { @@ -352,6 +352,30 @@ describe('OrderStateWatcher', () => { makerToken.address, maker, ZeroEx.NULL_ADDRESS, transferTokenAmount); })().catch(done); }); + it('should calculate full amount when all available and non-divisible', (done: DoneCallback) => { + (async () => { + const takerFee = ZeroEx.toBaseUnitAmount(new BigNumber(0), 18); + const makerFee = ZeroEx.toBaseUnitAmount(new BigNumber(2), 18); + const feeRecipient = taker; + signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync( + makerToken.address, takerToken.address, makerFee, takerFee, maker, + taker, fillableAmount, feeRecipient); + + const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker); + zeroEx.orderStateWatcher.addOrder(signedOrder); + + const callback = reportCallbackErrors(done)((orderState: OrderState) => { + const validOrderState = orderState as OrderStateValid; + const orderRelevantState = validOrderState.orderRelevantState; + expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal( + fillableAmount); + done(); + }); + zeroEx.orderStateWatcher.subscribe(callback); + await zeroEx.token.setProxyAllowanceAsync( + makerToken.address, maker, ZeroEx.toBaseUnitAmount(new BigNumber(100), 18)); + })().catch(done); + }); }); it('should emit orderStateInvalid when watched order cancelled', (done: DoneCallback) => { (async () => { |