diff options
Diffstat (limited to 'packages/0x.js/test/order_state_watcher_test.ts')
-rw-r--r-- | packages/0x.js/test/order_state_watcher_test.ts | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/packages/0x.js/test/order_state_watcher_test.ts b/packages/0x.js/test/order_state_watcher_test.ts index a112bac1d..3bf768769 100644 --- a/packages/0x.js/test/order_state_watcher_test.ts +++ b/packages/0x.js/test/order_state_watcher_test.ts @@ -235,7 +235,7 @@ describe('OrderStateWatcher', () => { ); })().catch(done); }); - describe('remainingFillable(M|T)akerTokenAmount', () => { + describe.only('remainingFillable(M|T)akerTokenAmount', () => { it('should calculate correct remaining fillable', (done: DoneCallback) => { (async () => { const takerFillableAmount = ZeroEx.toBaseUnitAmount(new BigNumber(10), 18); @@ -321,6 +321,39 @@ describe('OrderStateWatcher', () => { makerToken.address, maker, ZeroEx.NULL_ADDRESS, transferAmount); })().catch(done); }); + it('should equal ratio amount when fee balance is lowered', (done: DoneCallback) => { + (async () => { + const takerFee = ZeroEx.toBaseUnitAmount(new BigNumber(0), 18); + const makerFee = ZeroEx.toBaseUnitAmount(new BigNumber(5), 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); + + const remainingFeeAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), 18); + const transferFeeAmount = makerFee.sub(remainingFeeAmount); + + const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), 18); + const transferTokenAmount = makerFee.sub(remainingFeeAmount); + 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( + remainingAmount); + expect(orderRelevantState.remainingFillableTakerTokenAmount).to.be.bignumber.equal( + remainingAmount); + done(); + }); + zeroEx.orderStateWatcher.subscribe(callback); + await zeroEx.token.setProxyAllowanceAsync(zrxTokenAddress, maker, remainingAmount); + // await zeroEx.token.transferAsync( + // zrxTokenAddress, maker, ZeroEx.NULL_ADDRESS, transferAmount); + })().catch(done); + }); }); it('should emit orderStateInvalid when watched order cancelled', (done: DoneCallback) => { (async () => { |