Fix a bug causing fillOrdersUpTo validation to fail because of some extra orders being passed
This commit is contained in:
parent
7d9c357409
commit
1dda8c1468
@ -3,6 +3,7 @@
|
|||||||
## v0.34.0 - _TBD_
|
## v0.34.0 - _TBD_
|
||||||
|
|
||||||
* Update Kovan EtherToken artifact address to match TokenRegistry.
|
* Update Kovan EtherToken artifact address to match TokenRegistry.
|
||||||
|
* Fix the bug causing `zeroEx.exchange.fillOrdersUpToAsync` validation to fail if there were some extra orders passed (#470)
|
||||||
|
|
||||||
## v0.33.2 - _March 18, 2018_
|
## v0.33.2 - _March 18, 2018_
|
||||||
|
|
||||||
|
@ -281,6 +281,9 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
zrxTokenAddress,
|
zrxTokenAddress,
|
||||||
);
|
);
|
||||||
filledTakerTokenAmount = filledTakerTokenAmount.plus(singleFilledTakerTokenAmount);
|
filledTakerTokenAmount = filledTakerTokenAmount.plus(singleFilledTakerTokenAmount);
|
||||||
|
if (filledTakerTokenAmount.eq(fillTakerTokenAmount)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,6 +596,19 @@ describe('ExchangeWrapper', () => {
|
|||||||
const remainingFillAmount = fillableAmount.minus(1);
|
const remainingFillAmount = fillableAmount.minus(1);
|
||||||
expect(anotherFilledAmount).to.be.bignumber.equal(remainingFillAmount);
|
expect(anotherFilledAmount).to.be.bignumber.equal(remainingFillAmount);
|
||||||
});
|
});
|
||||||
|
it('should successfully fill up to specified amount and leave the rest of the orders untouched', async () => {
|
||||||
|
const txHash = await zeroEx.exchange.fillOrdersUpToAsync(
|
||||||
|
signedOrders,
|
||||||
|
fillableAmount,
|
||||||
|
shouldThrowOnInsufficientBalanceOrAllowance,
|
||||||
|
takerAddress,
|
||||||
|
);
|
||||||
|
await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||||
|
const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex);
|
||||||
|
const zeroAmount = await zeroEx.exchange.getFilledTakerAmountAsync(anotherOrderHashHex);
|
||||||
|
expect(filledAmount).to.be.bignumber.equal(fillableAmount);
|
||||||
|
expect(zeroAmount).to.be.bignumber.equal(0);
|
||||||
|
});
|
||||||
it('should successfully fill up to specified amount even if filling all orders would fail', async () => {
|
it('should successfully fill up to specified amount even if filling all orders would fail', async () => {
|
||||||
const missingBalance = new BigNumber(1); // User will still have enough balance to fill up to 9,
|
const missingBalance = new BigNumber(1); // User will still have enough balance to fill up to 9,
|
||||||
// but won't have 10 to fully fill all orders in a batch.
|
// but won't have 10 to fully fill all orders in a batch.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user