aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/exchange
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-03-21 08:34:58 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:17 +0800
commit751f9b9240fef07de5a604fa2345453a7656dfb2 (patch)
tree900e7b71f0b0b9d86f405e5b77dcd9f760c1860d /packages/contracts/test/exchange
parent1efba5979f2c11aa70845d2ef9f32b60e1bc6971 (diff)
downloaddexon-sol-tools-751f9b9240fef07de5a604fa2345453a7656dfb2.tar
dexon-sol-tools-751f9b9240fef07de5a604fa2345453a7656dfb2.tar.gz
dexon-sol-tools-751f9b9240fef07de5a604fa2345453a7656dfb2.tar.bz2
dexon-sol-tools-751f9b9240fef07de5a604fa2345453a7656dfb2.tar.lz
dexon-sol-tools-751f9b9240fef07de5a604fa2345453a7656dfb2.tar.xz
dexon-sol-tools-751f9b9240fef07de5a604fa2345453a7656dfb2.tar.zst
dexon-sol-tools-751f9b9240fef07de5a604fa2345453a7656dfb2.zip
Change from cancelOrdersBefore to cancelOrdersUpTo. The effect is that orders with salt <= to maker epoch will be cancelled (previously, it was salt < maker epoch)
Diffstat (limited to 'packages/contracts/test/exchange')
-rw-r--r--packages/contracts/test/exchange/core.ts50
1 files changed, 27 insertions, 23 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 53863c5d8..f28bb1215 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -745,62 +745,66 @@ describe('Exchange', () => {
describe('cancelOrdersBefore', () => {
it('should fail to set makerEpoch less than current makerEpoch', async () => {
const makerEpoch = new BigNumber(1);
- await exWrapper.cancelOrdersBeforeAsync(makerEpoch, makerAddress);
+ await exWrapper.cancelOrdersUpToAsync(makerEpoch, makerAddress);
const lesserMakerEpoch = new BigNumber(0);
return expect(
- exWrapper.cancelOrdersBeforeAsync(lesserMakerEpoch, makerAddress),
+ exWrapper.cancelOrdersUpToAsync(lesserMakerEpoch, makerAddress),
).to.be.rejectedWith(constants.REVERT);
});
it('should fail to set makerEpoch equal to existing makerEpoch', async () => {
const makerEpoch = new BigNumber(1);
- await exWrapper.cancelOrdersBeforeAsync(makerEpoch, makerAddress);
+ await exWrapper.cancelOrdersUpToAsync(makerEpoch, makerAddress);
return expect(
- exWrapper.cancelOrdersBeforeAsync(makerEpoch, makerAddress),
+ exWrapper.cancelOrdersUpToAsync(makerEpoch, makerAddress),
).to.be.rejectedWith(constants.REVERT);
});
it('should cancel only orders with a makerEpoch less than existing makerEpoch', async () => {
// Cancel all transactions with a makerEpoch less than 1
const makerEpoch = new BigNumber(1);
- await exWrapper.cancelOrdersBeforeAsync(makerEpoch, makerAddress);
+ await exWrapper.cancelOrdersUpToAsync(makerEpoch, makerAddress);
- // Create 3 orders with makerEpoch values: 0,1,2
- // Since we cancelled with makerEpoch=1, orders with makerEpoch<1 will not be processed
+ // Create 3 orders with makerEpoch values: 0,1,2,3
+ // Since we cancelled with makerEpoch=1, orders with makerEpoch<=1 will not be processed
balances = await dmyBalances.getAsync();
const signedOrders = await Promise.all([
orderFactory.newSignedOrder({
- makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(17), 18),
- takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(17), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(9), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(9), 18),
salt: new BigNumber(0)}),
orderFactory.newSignedOrder({
- makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(97), 18),
- takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(97), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(79), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(79), 18),
salt: new BigNumber(1)}),
orderFactory.newSignedOrder({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(979), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(979), 18),
salt: new BigNumber(2)}),
+ orderFactory.newSignedOrder({
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(7979), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(7979), 18),
+ salt: new BigNumber(3)}),
]);
await exWrapper.batchFillOrdersNoThrowAsync(signedOrders, takerAddress);
const newBalances = await dmyBalances.getAsync();
- const fillMakerTokenAmount = signedOrders[1].makerTokenAmount.add(signedOrders[2].makerTokenAmount);
- const fillTakerTokenAmount = signedOrders[1].takerTokenAmount.add(signedOrders[2].takerTokenAmount);
- const makerFeeAmount = signedOrders[1].makerFeeAmount.add(signedOrders[2].makerFeeAmount);
- const takerFeeAmount = signedOrders[1].takerFeeAmount.add(signedOrders[2].takerFeeAmount);
- expect(newBalances[makerAddress][signedOrders[2].makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[2].makerTokenAddress].minus(fillMakerTokenAmount),
+ const fillMakerTokenAmount = signedOrders[2].makerTokenAmount.add(signedOrders[3].makerTokenAmount);
+ const fillTakerTokenAmount = signedOrders[2].takerTokenAmount.add(signedOrders[3].takerTokenAmount);
+ const makerFeeAmount = signedOrders[2].makerFeeAmount.add(signedOrders[3].makerFeeAmount);
+ const takerFeeAmount = signedOrders[2].takerFeeAmount.add(signedOrders[3].takerFeeAmount);
+ expect(newBalances[makerAddress][signedOrders[3].makerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][signedOrders[3].makerTokenAddress].minus(fillMakerTokenAmount),
);
- expect(newBalances[makerAddress][signedOrders[2].takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[2].takerTokenAddress].add(fillTakerTokenAmount),
+ expect(newBalances[makerAddress][signedOrders[3].takerTokenAddress]).to.be.bignumber.equal(
+ balances[makerAddress][signedOrders[3].takerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(balances[makerAddress][zrx.address].minus(makerFeeAmount));
- expect(newBalances[takerAddress][signedOrders[2].takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[2].takerTokenAddress].minus(fillTakerTokenAmount),
+ expect(newBalances[takerAddress][signedOrders[3].takerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][signedOrders[3].takerTokenAddress].minus(fillTakerTokenAmount),
);
- expect(newBalances[takerAddress][signedOrders[2].makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[2].makerTokenAddress].add(fillMakerTokenAmount),
+ expect(newBalances[takerAddress][signedOrders[3].makerTokenAddress]).to.be.bignumber.equal(
+ balances[takerAddress][signedOrders[3].makerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(balances[takerAddress][zrx.address].minus(takerFeeAmount));
expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal(