diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-03-24 03:17:54 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-04-21 04:56:17 +0800 |
commit | 8f809e3a292c55e0f6440f9cf7c8746ede7ad583 (patch) | |
tree | 084ff67fed5dae3a3a39d452be1025800c264203 /packages/contracts/test/exchange | |
parent | 3f76985435c18c5b8087f1c681310b40613093e7 (diff) | |
download | dexon-sol-tools-8f809e3a292c55e0f6440f9cf7c8746ede7ad583.tar dexon-sol-tools-8f809e3a292c55e0f6440f9cf7c8746ede7ad583.tar.gz dexon-sol-tools-8f809e3a292c55e0f6440f9cf7c8746ede7ad583.tar.bz2 dexon-sol-tools-8f809e3a292c55e0f6440f9cf7c8746ede7ad583.tar.lz dexon-sol-tools-8f809e3a292c55e0f6440f9cf7c8746ede7ad583.tar.xz dexon-sol-tools-8f809e3a292c55e0f6440f9cf7c8746ede7ad583.tar.zst dexon-sol-tools-8f809e3a292c55e0f6440f9cf7c8746ede7ad583.zip |
Remove partial cancels
Diffstat (limited to 'packages/contracts/test/exchange')
-rw-r--r-- | packages/contracts/test/exchange/core.ts | 69 | ||||
-rw-r--r-- | packages/contracts/test/exchange/wrapper.ts | 4 |
2 files changed, 4 insertions, 69 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts index 69d059256..3919d43d8 100644 --- a/packages/contracts/test/exchange/core.ts +++ b/packages/contracts/test/exchange/core.ts @@ -631,16 +631,6 @@ describe('Exchange', () => { return expect(exWrapper.cancelOrderAsync(signedOrder, makerAddress)).to.be.rejectedWith(constants.REVERT); }); - it('should throw if takerTokenCancelAmount is 0', async () => { - signedOrder = orderFactory.newSignedOrder(); - - return expect( - exWrapper.cancelOrderAsync(signedOrder, makerAddress, { - takerTokenCancelAmount: new BigNumber(0), - }), - ).to.be.rejectedWith(constants.REVERT); - }); - it('should be able to cancel a full order', async () => { await exWrapper.cancelOrderAsync(signedOrder, makerAddress); await exWrapper.fillOrderAsync(signedOrder, takerAddress, { @@ -651,75 +641,22 @@ describe('Exchange', () => { expect(newBalances).to.be.deep.equal(balances); }); - it('should be able to cancel part of an order', async () => { - const takerTokenCancelAmount = signedOrder.takerTokenAmount.div(2); - await exWrapper.cancelOrderAsync(signedOrder, makerAddress, { - takerTokenCancelAmount, - }); - - const res = await exWrapper.fillOrderAsync(signedOrder, takerAddress, { - takerTokenFillAmount: signedOrder.takerTokenAmount, - }); - const log = logDecoder.decodeLogOrThrow(res.logs[0]) as LogWithDecodedArgs<LogFillContractEventArgs>; - expect(log.args.takerTokenFilledAmount).to.be.bignumber.equal( - signedOrder.takerTokenAmount.minus(takerTokenCancelAmount), - ); - - const newBalances = await dmyBalances.getAsync(); - const cancelMakerTokenAmount = takerTokenCancelAmount - .times(signedOrder.makerTokenAmount) - .dividedToIntegerBy(signedOrder.takerTokenAmount); - const makerFeePaid = signedOrder.makerFeeAmount - .times(cancelMakerTokenAmount) - .dividedToIntegerBy(signedOrder.makerTokenAmount); - const takerFeePaid = signedOrder.takerFeeAmount - .times(cancelMakerTokenAmount) - .dividedToIntegerBy(signedOrder.makerTokenAmount); - expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal( - balances[makerAddress][signedOrder.makerTokenAddress].minus(cancelMakerTokenAmount), - ); - expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal( - balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenCancelAmount), - ); - expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal( - balances[makerAddress][zrx.address].minus(makerFeePaid), - ); - expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal( - balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenCancelAmount), - ); - expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal( - balances[takerAddress][signedOrder.makerTokenAddress].add(cancelMakerTokenAmount), - ); - expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal( - balances[takerAddress][zrx.address].minus(takerFeePaid), - ); - expect(newBalances[feeRecipientAddress][zrx.address]).to.be.bignumber.equal( - balances[feeRecipientAddress][zrx.address].add(makerFeePaid.add(takerFeePaid)), - ); - }); - it('should log 1 event with correct arguments', async () => { const divisor = 2; - const res = await exWrapper.cancelOrderAsync(signedOrder, makerAddress, { - takerTokenCancelAmount: signedOrder.takerTokenAmount.div(divisor), - }); + const res = await exWrapper.cancelOrderAsync(signedOrder, makerAddress); expect(res.logs).to.have.length(1); const log = logDecoder.decodeLogOrThrow(res.logs[0]) as LogWithDecodedArgs<LogCancelContractEventArgs>; const logArgs = log.args; - const expectedCancelledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor); - const expectedCancelledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor); expect(signedOrder.makerAddress).to.be.equal(logArgs.makerAddress); expect(signedOrder.feeRecipientAddress).to.be.equal(logArgs.feeRecipientAddress); expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerTokenAddress); expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerTokenAddress); - expect(expectedCancelledMakerTokenAmount).to.be.bignumber.equal(logArgs.makerTokenCancelledAmount); - expect(expectedCancelledTakerTokenAmount).to.be.bignumber.equal(logArgs.takerTokenCancelledAmount); expect(orderUtils.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash); }); - it('should not log events if no value is cancelled', async () => { + it('should log an error if already cancelled', async () => { await exWrapper.cancelOrderAsync(signedOrder, makerAddress); const res = await exWrapper.cancelOrderAsync(signedOrder, makerAddress); @@ -729,7 +666,7 @@ describe('Exchange', () => { expect(errCode).to.be.equal(ExchangeContractErrs.ERROR_ORDER_FULLY_FILLED_OR_CANCELLED); }); - it('should not log events if order is expired', async () => { + it('should log error if order is expired', async () => { signedOrder = orderFactory.newSignedOrder({ expirationTimeSeconds: new BigNumber(Math.floor((Date.now() - 10000) / 1000)), }); diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts index 02e57b922..b87f45387 100644 --- a/packages/contracts/test/exchange/wrapper.ts +++ b/packages/contracts/test/exchange/wrapper.ts @@ -724,9 +724,7 @@ describe('Exchange', () => { describe('batchCancelOrders', () => { it('should be able to cancel multiple signedOrders', async () => { const takerTokenCancelAmounts = _.map(signedOrders, signedOrder => signedOrder.takerTokenAmount); - await exWrapper.batchCancelOrdersAsync(signedOrders, makerAddress, { - takerTokenCancelAmounts, - }); + await exWrapper.batchCancelOrdersAsync(signedOrders, makerAddress); await exWrapper.batchFillOrdersAsync(signedOrders, takerAddress, { takerTokenFillAmounts: takerTokenCancelAmounts, |