diff options
author | Jacob Evans <jacob@dekz.net> | 2017-11-20 08:10:50 +0800 |
---|---|---|
committer | Jacob Evans <jacob@dekz.net> | 2017-11-20 08:10:50 +0800 |
commit | d6589004c7f7c4d1af28c3aae110995da4c63531 (patch) | |
tree | 032001867a4c6d030e8a8ed2dc2742997c896fe0 /packages/0x.js/test/order_state_watcher_test.ts | |
parent | 519f1318c67ca4e40426cc23cce10dbb45985d6a (diff) | |
download | dexon-sol-tools-d6589004c7f7c4d1af28c3aae110995da4c63531.tar dexon-sol-tools-d6589004c7f7c4d1af28c3aae110995da4c63531.tar.gz dexon-sol-tools-d6589004c7f7c4d1af28c3aae110995da4c63531.tar.bz2 dexon-sol-tools-d6589004c7f7c4d1af28c3aae110995da4c63531.tar.lz dexon-sol-tools-d6589004c7f7c4d1af28c3aae110995da4c63531.tar.xz dexon-sol-tools-d6589004c7f7c4d1af28c3aae110995da4c63531.tar.zst dexon-sol-tools-d6589004c7f7c4d1af28c3aae110995da4c63531.zip |
fix bug when fees and partial asymmetric
Diffstat (limited to 'packages/0x.js/test/order_state_watcher_test.ts')
-rw-r--r-- | packages/0x.js/test/order_state_watcher_test.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/0x.js/test/order_state_watcher_test.ts b/packages/0x.js/test/order_state_watcher_test.ts index 9d432a713..8ab4939c0 100644 --- a/packages/0x.js/test/order_state_watcher_test.ts +++ b/packages/0x.js/test/order_state_watcher_test.ts @@ -321,6 +321,32 @@ describe('OrderStateWatcher', () => { makerToken.address, maker, ZeroEx.NULL_ADDRESS, transferAmount); })().catch(done); }); + it('should equal remaining amount when partially cancelled and order has fees', (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 remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(4), 18); + const transferTokenAmount = makerFee.sub(remainingTokenAmount); + 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( + remainingTokenAmount); + done(); + }); + zeroEx.orderStateWatcher.subscribe(callback); + await zeroEx.exchange.cancelOrderAsync(signedOrder, transferTokenAmount); + })().catch(done); + }); it('should equal ratio amount when fee balance is lowered', (done: DoneCallback) => { (async () => { const takerFee = ZeroEx.toBaseUnitAmount(new BigNumber(0), 18); |