diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-18 20:06:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-18 20:06:08 +0800 |
commit | 3973dec9944a10c62ec6c3d15d973a00a6ea45a6 (patch) | |
tree | 73f1528a36b8fc8a0778e164b1579eb5865d944a /contracts/protocol/test/exchange/internal.ts | |
parent | bef30e4209b26c8d4f443f8672e9acb9471c6a37 (diff) | |
parent | c8212f1d4d255120e5e683664b86f1830fb45ae6 (diff) | |
download | dexon-sol-tools-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.tar dexon-sol-tools-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.tar.gz dexon-sol-tools-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.tar.bz2 dexon-sol-tools-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.tar.lz dexon-sol-tools-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.tar.xz dexon-sol-tools-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.tar.zst dexon-sol-tools-3973dec9944a10c62ec6c3d15d973a00a6ea45a6.zip |
Merge pull request #1517 from 0xProject/feature/bignumber-8.0
Bignumber 8.0
Diffstat (limited to 'contracts/protocol/test/exchange/internal.ts')
-rw-r--r-- | contracts/protocol/test/exchange/internal.ts | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/contracts/protocol/test/exchange/internal.ts b/contracts/protocol/test/exchange/internal.ts index 972f5efb6..6ff1fdc2f 100644 --- a/contracts/protocol/test/exchange/internal.ts +++ b/contracts/protocol/test/exchange/internal.ts @@ -90,14 +90,14 @@ describe('Exchange core internal functions', () => { if (target.eq(0)) { return false; } - const product = numerator.mul(target); + const product = numerator.multipliedBy(target); const remainder = product.mod(denominator); - const remainderTimes1000 = remainder.mul('1000'); + const remainderTimes1000 = remainder.multipliedBy('1000'); const isError = remainderTimes1000.gte(product); - if (product.greaterThan(MAX_UINT256)) { + if (product.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } - if (remainderTimes1000.greaterThan(MAX_UINT256)) { + if (remainderTimes1000.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } return isError; @@ -117,15 +117,15 @@ describe('Exchange core internal functions', () => { if (target.eq(0)) { return false; } - const product = numerator.mul(target); + const product = numerator.multipliedBy(target); const remainder = product.mod(denominator); - const error = denominator.sub(remainder).mod(denominator); - const errorTimes1000 = error.mul('1000'); + const error = denominator.minus(remainder).mod(denominator); + const errorTimes1000 = error.multipliedBy('1000'); const isError = errorTimes1000.gte(product); - if (product.greaterThan(MAX_UINT256)) { + if (product.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } - if (errorTimes1000.greaterThan(MAX_UINT256)) { + if (errorTimes1000.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } return isError; @@ -143,8 +143,8 @@ describe('Exchange core internal functions', () => { if (isRoundingError) { throw roundingErrorForCall; } - const product = numerator.mul(target); - if (product.greaterThan(MAX_UINT256)) { + const product = numerator.multipliedBy(target); + if (product.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } return product.dividedToIntegerBy(denominator); @@ -177,8 +177,8 @@ describe('Exchange core internal functions', () => { _.cloneDeep(totalFillResults), singleFillResults, (totalVal: BigNumber, singleVal: BigNumber) => { - const newTotal = totalVal.add(singleVal); - if (newTotal.greaterThan(MAX_UINT256)) { + const newTotal = totalVal.plus(singleVal); + if (newTotal.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } return newTotal; @@ -271,8 +271,8 @@ describe('Exchange core internal functions', () => { if (denominator.eq(0)) { throw divisionByZeroErrorForCall; } - const product = numerator.mul(target); - if (product.greaterThan(MAX_UINT256)) { + const product = numerator.multipliedBy(target); + if (product.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } return product.dividedToIntegerBy(denominator); @@ -301,16 +301,16 @@ describe('Exchange core internal functions', () => { if (denominator.eq(0)) { throw divisionByZeroErrorForCall; } - const product = numerator.mul(target); - const offset = product.add(denominator.sub(1)); - if (offset.greaterThan(MAX_UINT256)) { + const product = numerator.multipliedBy(target); + const offset = product.plus(denominator.minus(1)); + if (offset.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } const result = offset.dividedToIntegerBy(denominator); if (product.mod(denominator).eq(0)) { - expect(result.mul(denominator)).to.be.bignumber.eq(product); + expect(result.multipliedBy(denominator)).to.be.bignumber.eq(product); } else { - expect(result.mul(denominator)).to.be.bignumber.gt(product); + expect(result.multipliedBy(denominator)).to.be.bignumber.gt(product); } return result; } @@ -358,16 +358,16 @@ describe('Exchange core internal functions', () => { if (isRoundingError) { throw roundingErrorForCall; } - const product = numerator.mul(target); - const offset = product.add(denominator.sub(1)); - if (offset.greaterThan(MAX_UINT256)) { + const product = numerator.multipliedBy(target); + const offset = product.plus(denominator.minus(1)); + if (offset.isGreaterThan(MAX_UINT256)) { throw overflowErrorForCall; } const result = offset.dividedToIntegerBy(denominator); if (product.mod(denominator).eq(0)) { - expect(result.mul(denominator)).to.be.bignumber.eq(product); + expect(result.multipliedBy(denominator)).to.be.bignumber.eq(product); } else { - expect(result.mul(denominator)).to.be.bignumber.gt(product); + expect(result.multipliedBy(denominator)).to.be.bignumber.gt(product); } return result; } @@ -433,8 +433,8 @@ describe('Exchange core internal functions', () => { // tslint:disable-next-line:no-unused-variable orderHash: string, ): Promise<BigNumber> { - const totalFilledAmount = takerAssetFilledAmount.add(orderTakerAssetFilledAmount); - if (totalFilledAmount.greaterThan(MAX_UINT256)) { + const totalFilledAmount = takerAssetFilledAmount.plus(orderTakerAssetFilledAmount); + if (totalFilledAmount.isGreaterThan(MAX_UINT256)) { throw overflowErrorForSendTransaction; } return totalFilledAmount; |