diff options
author | Jacob Evans <jacob@dekz.net> | 2017-11-21 11:00:21 +0800 |
---|---|---|
committer | Jacob Evans <jacob@dekz.net> | 2017-11-21 11:00:21 +0800 |
commit | 43128234bbb9715094c24c99b6a001a5290fcefd (patch) | |
tree | 70e5ce5567f445c647a9038acba17b69434a945e /packages/0x.js | |
parent | bbcee8dfa735ae8261b29cd917a99c97c551ed5d (diff) | |
download | dexon-sol-tools-43128234bbb9715094c24c99b6a001a5290fcefd.tar dexon-sol-tools-43128234bbb9715094c24c99b6a001a5290fcefd.tar.gz dexon-sol-tools-43128234bbb9715094c24c99b6a001a5290fcefd.tar.bz2 dexon-sol-tools-43128234bbb9715094c24c99b6a001a5290fcefd.tar.lz dexon-sol-tools-43128234bbb9715094c24c99b6a001a5290fcefd.tar.xz dexon-sol-tools-43128234bbb9715094c24c99b6a001a5290fcefd.tar.zst dexon-sol-tools-43128234bbb9715094c24c99b6a001a5290fcefd.zip |
setting a failed test
Diffstat (limited to 'packages/0x.js')
-rw-r--r-- | packages/0x.js/test/remaining_fillable_calculator_test.ts | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/packages/0x.js/test/remaining_fillable_calculator_test.ts b/packages/0x.js/test/remaining_fillable_calculator_test.ts index f1821551f..5d7cd9277 100644 --- a/packages/0x.js/test/remaining_fillable_calculator_test.ts +++ b/packages/0x.js/test/remaining_fillable_calculator_test.ts @@ -25,7 +25,7 @@ describe.only('RemainingFillableCalculator', () => { const zero: BigNumber = new BigNumber(0); const zeroAddress = '0x0'; const signature: ECSignature = { v: 27, r: '', s: ''}; - before(async () => { + beforeEach(async () => { [makerToken, takerToken, zrxToken] = ['0x1', '0x2', '0x3']; [makerAmount, takerAmount, makerFee] = [ZeroEx.toBaseUnitAmount(new BigNumber(50), 18), ZeroEx.toBaseUnitAmount(new BigNumber(5), 18), @@ -49,15 +49,31 @@ describe.only('RemainingFillableCalculator', () => { salt: zero, expirationUnixTimestampSec: zero }; } - it('calculates the correct amount when partially filled and funds available', () => { - signedOrder = buildSignedOrder(); - remainingMakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18); - calculator = new RemainingFillableCalculator(signedOrder, zrxToken, - transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount); - expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount); - }); describe('Maker token is NOT ZRX', () => { - it('calculates the amount to be 0 when all fee funds move', () => { + it('calculates the correct amount when balance is less than remaining fillable', () => { + signedOrder = buildSignedOrder(); + const partiallyFilledAmount = ZeroEx.toBaseUnitAmount(new BigNumber(2), 18); + remainingMakerTokenAmount = signedOrder.makerTokenAmount.minus(partiallyFilledAmount); + transferrableMakerTokenAmount = remainingMakerTokenAmount.minus(partiallyFilledAmount); + calculator = new RemainingFillableCalculator(signedOrder, zrxToken, + transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount); + expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(transferrableMakerTokenAmount); + }); + it('calculates the correct amount when unfilled and funds available', () => { + signedOrder = buildSignedOrder(); + remainingMakerTokenAmount = signedOrder.makerTokenAmount; + calculator = new RemainingFillableCalculator(signedOrder, zrxToken, + transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount); + expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount); + }); + it('calculates the correct amount when partially filled and funds available', () => { + signedOrder = buildSignedOrder(); + remainingMakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18); + calculator = new RemainingFillableCalculator(signedOrder, zrxToken, + transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount); + expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount); + }); + it('calculates the amount to be 0 when all fee funds are transferred', () => { signedOrder = buildSignedOrder(); transferrableMakerFeeTokenAmount = zero; remainingMakerTokenAmount = signedOrder.makerTokenAmount; @@ -67,9 +83,28 @@ describe.only('RemainingFillableCalculator', () => { }); }); describe('Maker Token is ZRX', () => { - before(async () => { + beforeEach(async () => { makerToken = zrxToken; }); + it('calculates the correct amount when balance is less than remaining fillable', () => { + signedOrder = buildSignedOrder(); + const partiallyFilledAmount = ZeroEx.toBaseUnitAmount(new BigNumber(2), 18); + remainingMakerTokenAmount = signedOrder.makerTokenAmount.minus(partiallyFilledAmount); + transferrableMakerTokenAmount = remainingMakerTokenAmount.minus(partiallyFilledAmount); + transferrableMakerFeeTokenAmount = transferrableMakerTokenAmount; + calculator = new RemainingFillableCalculator(signedOrder, zrxToken, + transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount); + expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(transferrableMakerTokenAmount); + }); + it('calculates the correct amount when unfilled and funds available', () => { + signedOrder = buildSignedOrder(); + transferrableMakerTokenAmount = makerAmount.plus(makerFee); + transferrableMakerFeeTokenAmount = transferrableMakerTokenAmount; + remainingMakerTokenAmount = signedOrder.makerTokenAmount; + calculator = new RemainingFillableCalculator(signedOrder, zrxToken, + transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount); + expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount); + }); it('calculates the correct amount when partially filled and funds available', () => { signedOrder = buildSignedOrder(); remainingMakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), 18); @@ -77,7 +112,7 @@ describe.only('RemainingFillableCalculator', () => { transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount, remainingMakerTokenAmount); expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount); }); - it('calculates the amount to be 0 when all fee funds move', () => { + it('calculates the amount to be 0 when all fee funds are transferred', () => { signedOrder = buildSignedOrder(); transferrableMakerTokenAmount = zero; transferrableMakerFeeTokenAmount = zero; |