diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-02-09 03:51:09 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-04-21 04:56:16 +0800 |
commit | 6b897f6fd2b3bf894662f11f67ebb555f20c2464 (patch) | |
tree | e5eab4fea3905cc55ac02bc4dc0ceddd3b76027a /packages/contracts/test/exchange/core.ts | |
parent | 389f1cde519f9c6824bc1599aedaa0c3c0b792c2 (diff) | |
download | dexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.tar dexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.tar.gz dexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.tar.bz2 dexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.tar.lz dexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.tar.xz dexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.tar.zst dexon-sol-tools-6b897f6fd2b3bf894662f11f67ebb555f20c2464.zip |
Get tests to build
Diffstat (limited to 'packages/contracts/test/exchange/core.ts')
-rw-r--r-- | packages/contracts/test/exchange/core.ts | 213 |
1 files changed, 95 insertions, 118 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts index 689b11062..0a9b7b2c9 100644 --- a/packages/contracts/test/exchange/core.ts +++ b/packages/contracts/test/exchange/core.ts @@ -1,4 +1,5 @@ import { LogWithDecodedArgs, SignedOrder, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js'; + import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils'; import { BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; @@ -130,18 +131,6 @@ describe('Exchange', () => { it('should include transferViaTokenTransferProxy', () => { expect((exchange as any).transferViaTokenTransferProxy).to.be.undefined(); }); - - it('should include isTransferable', () => { - expect((exchange as any).isTransferable).to.be.undefined(); - }); - - it('should include getBalance', () => { - expect((exchange as any).getBalance).to.be.undefined(); - }); - - it('should include getAllowance', () => { - expect((exchange as any).getAllowance).to.be.undefined(); - }); }); describe('fillOrder', () => { @@ -163,7 +152,7 @@ describe('Exchange', () => { const fillTakerTokenAmount1 = new BigNumber(2); await exWrapper.fillOrderAsync(signedOrder, taker, { - fillTakerTokenAmount: fillTakerTokenAmount1, + takerTokenFillAmount: fillTakerTokenAmount1, }); const filledTakerTokenAmountAfter1 = await zeroEx.exchange.getFilledTakerAmountAsync( @@ -173,7 +162,7 @@ describe('Exchange', () => { const fillTakerTokenAmount2 = new BigNumber(1); await exWrapper.fillOrderAsync(signedOrder, taker, { - fillTakerTokenAmount: fillTakerTokenAmount2, + takerTokenFillAmount: fillTakerTokenAmount2, }); const filledTakerTokenAmountAfter2 = await zeroEx.exchange.getFilledTakerAmountAsync( @@ -193,45 +182,45 @@ describe('Exchange', () => { ); expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0); - const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2); - await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount }); + const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2); + await exWrapper.fillOrderAsync(signedOrder, taker, { takerTokenFillAmount }); const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync( ZeroEx.getOrderHashHex(signedOrder), ); - expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount); + expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(takerTokenFillAmount); const newBalances = await dmyBalances.getAsync(); - const fillMakerTokenAmount = fillTakerTokenAmount + const makerTokenFillAmount = takerTokenFillAmount .times(signedOrder.makerTokenAmount) .dividedToIntegerBy(signedOrder.takerTokenAmount); - const paidMakerFee = signedOrder.makerFee - .times(fillMakerTokenAmount) + const makerFeePaid = signedOrder.makerFee + .times(makerTokenFillAmount) .dividedToIntegerBy(signedOrder.makerTokenAmount); - const paidTakerFee = signedOrder.takerFee - .times(fillMakerTokenAmount) + const takerFeePaid = signedOrder.takerFee + .times(makerTokenFillAmount) .dividedToIntegerBy(signedOrder.makerTokenAmount); expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal( - balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount), + balances[maker][signedOrder.makerTokenAddress].minus(makerTokenFillAmount), ); expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal( - balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount), + balances[maker][signedOrder.takerTokenAddress].add(takerTokenFillAmount), ); expect(newBalances[maker][zrx.address]).to.be.bignumber.equal( - balances[maker][zrx.address].minus(paidMakerFee), + balances[maker][zrx.address].minus(makerFeePaid), ); expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal( - balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount), + balances[taker][signedOrder.takerTokenAddress].minus(takerTokenFillAmount), ); expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal( - balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount), + balances[taker][signedOrder.makerTokenAddress].add(makerTokenFillAmount), ); expect(newBalances[taker][zrx.address]).to.be.bignumber.equal( - balances[taker][zrx.address].minus(paidTakerFee), + balances[taker][zrx.address].minus(takerFeePaid), ); expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal( - balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)), + balances[feeRecipient][zrx.address].add(makerFeePaid.add(takerFeePaid)), ); }); @@ -246,45 +235,45 @@ describe('Exchange', () => { ); expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0); - const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2); - await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount }); + const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2); + await exWrapper.fillOrderAsync(signedOrder, taker, { takerTokenFillAmount }); const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync( ZeroEx.getOrderHashHex(signedOrder), ); - expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount); + expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(takerTokenFillAmount); const newBalances = await dmyBalances.getAsync(); - const fillMakerTokenAmount = fillTakerTokenAmount + const makerTokenFillAmount = takerTokenFillAmount .times(signedOrder.makerTokenAmount) .dividedToIntegerBy(signedOrder.takerTokenAmount); - const paidMakerFee = signedOrder.makerFee - .times(fillMakerTokenAmount) + const makerFeePaid = signedOrder.makerFee + .times(makerTokenFillAmount) .dividedToIntegerBy(signedOrder.makerTokenAmount); - const paidTakerFee = signedOrder.takerFee - .times(fillMakerTokenAmount) + const takerFeePaid = signedOrder.takerFee + .times(makerTokenFillAmount) .dividedToIntegerBy(signedOrder.makerTokenAmount); expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal( - balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount), + balances[maker][signedOrder.makerTokenAddress].minus(makerTokenFillAmount), ); expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal( - balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount), + balances[maker][signedOrder.takerTokenAddress].add(takerTokenFillAmount), ); expect(newBalances[maker][zrx.address]).to.be.bignumber.equal( - balances[maker][zrx.address].minus(paidMakerFee), + balances[maker][zrx.address].minus(makerFeePaid), ); expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal( - balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount), + balances[taker][signedOrder.takerTokenAddress].minus(takerTokenFillAmount), ); expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal( - balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount), + balances[taker][signedOrder.makerTokenAddress].add(makerTokenFillAmount), ); expect(newBalances[taker][zrx.address]).to.be.bignumber.equal( - balances[taker][zrx.address].minus(paidTakerFee), + balances[taker][zrx.address].minus(takerFeePaid), ); expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal( - balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)), + balances[feeRecipient][zrx.address].add(makerFeePaid.add(takerFeePaid)), ); }); @@ -299,45 +288,45 @@ describe('Exchange', () => { ); expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0); - const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2); - await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount }); + const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2); + await exWrapper.fillOrderAsync(signedOrder, taker, { takerTokenFillAmount }); const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync( ZeroEx.getOrderHashHex(signedOrder), ); - expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount); + expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(takerTokenFillAmount); const newBalances = await dmyBalances.getAsync(); - const fillMakerTokenAmount = fillTakerTokenAmount + const makerTokenFillAmount = takerTokenFillAmount .times(signedOrder.makerTokenAmount) .dividedToIntegerBy(signedOrder.takerTokenAmount); - const paidMakerFee = signedOrder.makerFee - .times(fillMakerTokenAmount) + const makerFeePaid = signedOrder.makerFee + .times(makerTokenFillAmount) .dividedToIntegerBy(signedOrder.makerTokenAmount); - const paidTakerFee = signedOrder.takerFee - .times(fillMakerTokenAmount) + const takerFeePaid = signedOrder.takerFee + .times(makerTokenFillAmount) .dividedToIntegerBy(signedOrder.makerTokenAmount); expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal( - balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount), + balances[maker][signedOrder.makerTokenAddress].minus(makerTokenFillAmount), ); expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal( - balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount), + balances[maker][signedOrder.takerTokenAddress].add(takerTokenFillAmount), ); expect(newBalances[maker][zrx.address]).to.be.bignumber.equal( - balances[maker][zrx.address].minus(paidMakerFee), + balances[maker][zrx.address].minus(makerFeePaid), ); expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal( - balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount), + balances[taker][signedOrder.takerTokenAddress].minus(takerTokenFillAmount), ); expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal( - balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount), + balances[taker][signedOrder.makerTokenAddress].add(makerTokenFillAmount), ); expect(newBalances[taker][zrx.address]).to.be.bignumber.equal( - balances[taker][zrx.address].minus(paidTakerFee), + balances[taker][zrx.address].minus(takerFeePaid), ); expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal( - balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)), + balances[feeRecipient][zrx.address].add(makerFeePaid.add(takerFeePaid)), ); }); @@ -353,59 +342,59 @@ describe('Exchange', () => { ); expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0); - const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2); - await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount }); + const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2); + await exWrapper.fillOrderAsync(signedOrder, taker, { takerTokenFillAmount }); const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync( ZeroEx.getOrderHashHex(signedOrder), ); - const expectedFillAmountTAfter = fillTakerTokenAmount.add(filledTakerTokenAmountBefore); + const expectedFillAmountTAfter = takerTokenFillAmount.add(filledTakerTokenAmountBefore); expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(expectedFillAmountTAfter); const newBalances = await dmyBalances.getAsync(); - const fillMakerTokenAmount = fillTakerTokenAmount + const makerTokenFillAmount = takerTokenFillAmount .times(signedOrder.makerTokenAmount) .dividedToIntegerBy(signedOrder.takerTokenAmount); - const paidMakerFee = signedOrder.makerFee - .times(fillMakerTokenAmount) + const makerFeePaid = signedOrder.makerFee + .times(makerTokenFillAmount) .dividedToIntegerBy(signedOrder.makerTokenAmount); - const paidTakerFee = signedOrder.takerFee - .times(fillMakerTokenAmount) + const takerFeePaid = signedOrder.takerFee + .times(makerTokenFillAmount) .dividedToIntegerBy(signedOrder.makerTokenAmount); expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal( - balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount), + balances[maker][signedOrder.makerTokenAddress].minus(makerTokenFillAmount), ); expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal( - balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount), + balances[maker][signedOrder.takerTokenAddress].add(takerTokenFillAmount), ); expect(newBalances[maker][zrx.address]).to.be.bignumber.equal( - balances[maker][zrx.address].minus(paidMakerFee), + balances[maker][zrx.address].minus(makerFeePaid), ); expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal( - balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount), + balances[taker][signedOrder.takerTokenAddress].minus(takerTokenFillAmount), ); expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal( - balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount), + balances[taker][signedOrder.makerTokenAddress].add(makerTokenFillAmount), ); expect(newBalances[taker][zrx.address]).to.be.bignumber.equal( - balances[taker][zrx.address].minus(paidTakerFee), + balances[taker][zrx.address].minus(takerFeePaid), ); expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal( - balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)), + balances[feeRecipient][zrx.address].add(makerFeePaid.add(takerFeePaid)), ); }); - it('should fill remaining value if fillTakerTokenAmount > remaining takerTokenAmount', async () => { - const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2); - await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount }); + it('should fill remaining value if takerTokenFillAmount > remaining takerTokenAmount', async () => { + const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2); + await exWrapper.fillOrderAsync(signedOrder, taker, { takerTokenFillAmount }); const res = await exWrapper.fillOrderAsync(signedOrder, taker, { - fillTakerTokenAmount: signedOrder.takerTokenAmount, + takerTokenFillAmount: signedOrder.takerTokenAmount, }); const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>; expect(log.args.filledTakerTokenAmount).to.be.bignumber.equal( - signedOrder.takerTokenAmount.minus(fillTakerTokenAmount), + signedOrder.takerTokenAmount.minus(takerTokenFillAmount), ); const newBalances = await dmyBalances.getAsync(); @@ -435,7 +424,7 @@ describe('Exchange', () => { it('should log 1 event with the correct arguments when order has a feeRecipient', async () => { const divisor = 2; const res = await exWrapper.fillOrderAsync(signedOrder, taker, { - fillTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor), + takerTokenFillAmount: signedOrder.takerTokenAmount.div(divisor), }); expect(res.logs).to.have.length(1); @@ -454,8 +443,8 @@ describe('Exchange', () => { expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerToken); expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.filledMakerTokenAmount); expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.filledTakerTokenAmount); - expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.paidMakerFee); - expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.paidTakerFee); + expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.makerFeePaid); + expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.takerFeePaid); expect(expectedTokens).to.be.equal(logArgs.tokens); expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash); }); @@ -466,7 +455,7 @@ describe('Exchange', () => { }); const divisor = 2; const res = await exWrapper.fillOrderAsync(signedOrder, taker, { - fillTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor), + takerTokenFillAmount: signedOrder.takerTokenAmount.div(divisor), }); expect(res.logs).to.have.length(1); @@ -485,8 +474,8 @@ describe('Exchange', () => { expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerToken); expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.filledMakerTokenAmount); expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.filledTakerTokenAmount); - expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.paidMakerFee); - expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.paidTakerFee); + expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.makerFeePaid); + expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.takerFeePaid); expect(expectedTokens).to.be.equal(logArgs.tokens); expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash); }); @@ -527,12 +516,12 @@ describe('Exchange', () => { return expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT); }); - it('should throw if fillTakerTokenAmount is 0', async () => { + it('should throw if takerTokenFillAmount is 0', async () => { signedOrder = await orderFactory.newSignedOrderAsync(); return expect( exWrapper.fillOrderAsync(signedOrder, taker, { - fillTakerTokenAmount: new BigNumber(0), + takerTokenFillAmount: new BigNumber(0), }), ).to.be.rejectedWith(constants.REVERT); }); @@ -578,11 +567,7 @@ describe('Exchange', () => { takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18), }); - return expect( - exWrapper.fillOrderAsync(signedOrder, taker, { - shouldThrowOnInsufficientBalanceOrAllowance: true, - }), - ).to.be.rejectedWith(constants.REVERT); + return expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT); }); it('should not change balances if maker allowances are too low to fill order and \ @@ -600,11 +585,7 @@ describe('Exchange', () => { it('should throw if maker allowances are too low to fill order and \ shouldThrowOnInsufficientBalanceOrAllowance = true', async () => { await rep.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: maker }); - expect( - exWrapper.fillOrderAsync(signedOrder, taker, { - shouldThrowOnInsufficientBalanceOrAllowance: true, - }), - ).to.be.rejectedWith(constants.REVERT); + expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT); await rep.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, { from: maker, }); @@ -625,11 +606,7 @@ describe('Exchange', () => { it('should throw if taker allowances are too low to fill order and \ shouldThrowOnInsufficientBalanceOrAllowance = true', async () => { await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: taker }); - expect( - exWrapper.fillOrderAsync(signedOrder, taker, { - shouldThrowOnInsufficientBalanceOrAllowance: true, - }), - ).to.be.rejectedWith(constants.REVERT); + expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT); await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, { from: taker, }); @@ -765,12 +742,12 @@ describe('Exchange', () => { return expect(exWrapper.cancelOrderAsync(signedOrder, maker)).to.be.rejectedWith(constants.REVERT); }); - it('should throw if cancelTakerTokenAmount is 0', async () => { + it('should throw if takerTokenCancelAmount is 0', async () => { signedOrder = await orderFactory.newSignedOrderAsync(); return expect( exWrapper.cancelOrderAsync(signedOrder, maker, { - cancelTakerTokenAmount: new BigNumber(0), + takerTokenCancelAmount: new BigNumber(0), }), ).to.be.rejectedWith(constants.REVERT); }); @@ -778,7 +755,7 @@ describe('Exchange', () => { it('should be able to cancel a full order', async () => { await exWrapper.cancelOrderAsync(signedOrder, maker); await exWrapper.fillOrderAsync(signedOrder, taker, { - fillTakerTokenAmount: signedOrder.takerTokenAmount.div(2), + takerTokenFillAmount: signedOrder.takerTokenAmount.div(2), }); const newBalances = await dmyBalances.getAsync(); @@ -786,56 +763,56 @@ describe('Exchange', () => { }); it('should be able to cancel part of an order', async () => { - const cancelTakerTokenAmount = signedOrder.takerTokenAmount.div(2); + const takerTokenCancelAmount = signedOrder.takerTokenAmount.div(2); await exWrapper.cancelOrderAsync(signedOrder, maker, { - cancelTakerTokenAmount, + takerTokenCancelAmount, }); const res = await exWrapper.fillOrderAsync(signedOrder, taker, { - fillTakerTokenAmount: signedOrder.takerTokenAmount, + takerTokenFillAmount: signedOrder.takerTokenAmount, }); const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>; expect(log.args.filledTakerTokenAmount).to.be.bignumber.equal( - signedOrder.takerTokenAmount.minus(cancelTakerTokenAmount), + signedOrder.takerTokenAmount.minus(takerTokenCancelAmount), ); const newBalances = await dmyBalances.getAsync(); - const cancelMakerTokenAmount = cancelTakerTokenAmount + const cancelMakerTokenAmount = takerTokenCancelAmount .times(signedOrder.makerTokenAmount) .dividedToIntegerBy(signedOrder.takerTokenAmount); - const paidMakerFee = signedOrder.makerFee + const makerFeePaid = signedOrder.makerFee .times(cancelMakerTokenAmount) .dividedToIntegerBy(signedOrder.makerTokenAmount); - const paidTakerFee = signedOrder.takerFee + const takerFeePaid = signedOrder.takerFee .times(cancelMakerTokenAmount) .dividedToIntegerBy(signedOrder.makerTokenAmount); expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal( balances[maker][signedOrder.makerTokenAddress].minus(cancelMakerTokenAmount), ); expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal( - balances[maker][signedOrder.takerTokenAddress].add(cancelTakerTokenAmount), + balances[maker][signedOrder.takerTokenAddress].add(takerTokenCancelAmount), ); expect(newBalances[maker][zrx.address]).to.be.bignumber.equal( - balances[maker][zrx.address].minus(paidMakerFee), + balances[maker][zrx.address].minus(makerFeePaid), ); expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal( - balances[taker][signedOrder.takerTokenAddress].minus(cancelTakerTokenAmount), + balances[taker][signedOrder.takerTokenAddress].minus(takerTokenCancelAmount), ); expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal( balances[taker][signedOrder.makerTokenAddress].add(cancelMakerTokenAmount), ); expect(newBalances[taker][zrx.address]).to.be.bignumber.equal( - balances[taker][zrx.address].minus(paidTakerFee), + balances[taker][zrx.address].minus(takerFeePaid), ); expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal( - balances[feeRecipient][zrx.address].add(paidMakerFee.add(paidTakerFee)), + balances[feeRecipient][zrx.address].add(makerFeePaid.add(takerFeePaid)), ); }); it('should log 1 event with correct arguments', async () => { const divisor = 2; const res = await exWrapper.cancelOrderAsync(signedOrder, maker, { - cancelTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor), + takerTokenCancelAmount: signedOrder.takerTokenAmount.div(divisor), }); expect(res.logs).to.have.length(1); |