aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/test
diff options
context:
space:
mode:
Diffstat (limited to 'packages/0x.js/test')
-rw-r--r--packages/0x.js/test/order_state_watcher_test.ts28
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 () => {