diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-14 22:50:32 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2019-01-15 23:25:24 +0800 |
commit | c3afc13dd660348e99b727c2dd01930eec8d99c3 (patch) | |
tree | 9a05e88e55200fdf72d08af10b5a753535e23256 /contracts/protocol/test/utils | |
parent | f570f80674c22f69712c45e8e3c48e948b51f357 (diff) | |
download | dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.tar dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.tar.gz dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.tar.bz2 dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.tar.lz dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.tar.xz dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.tar.zst dexon-sol-tools-c3afc13dd660348e99b727c2dd01930eec8d99c3.zip |
Upgrade bignumber.js version
Diffstat (limited to 'contracts/protocol/test/utils')
-rw-r--r-- | contracts/protocol/test/utils/fill_order_combinatorial_utils.ts | 6 | ||||
-rw-r--r-- | contracts/protocol/test/utils/match_order_tester.ts | 24 |
2 files changed, 16 insertions, 14 deletions
diff --git a/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts b/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts index 2fd33bebd..c2f530e5b 100644 --- a/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts +++ b/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts @@ -469,7 +469,7 @@ export class FillOrderCombinatorialUtils { const remainingTakerAmountToFill = signedOrder.takerAssetAmount.minus(alreadyFilledTakerAmount); const expFilledTakerAmount = takerAssetFillAmount.gt(remainingTakerAmountToFill) ? remainingTakerAmountToFill - : alreadyFilledTakerAmount.add(takerAssetFillAmount); + : alreadyFilledTakerAmount.plus(takerAssetFillAmount); const expFilledMakerAmount = orderUtils.getPartialAmountFloor( expFilledTakerAmount, @@ -644,7 +644,7 @@ export class FillOrderCombinatorialUtils { break; case TakerAssetFillAmountScenario.GreaterThanRemainingFillableTakerAssetAmount: - takerAssetFillAmount = fillableTakerAssetAmount.add(1); + takerAssetFillAmount = fillableTakerAssetAmount.plus(1); break; case TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount: @@ -657,7 +657,7 @@ export class FillOrderCombinatorialUtils { 'Cannot test `TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount` together with ERC721 assets since orders involving ERC721 must always be filled exactly.', ); } - takerAssetFillAmount = fillableTakerAssetAmount.div(2).floor(); + takerAssetFillAmount = fillableTakerAssetAmount.div(2).integerValue(BigNumber.ROUND_FLOOR); break; default: diff --git a/contracts/protocol/test/utils/match_order_tester.ts b/contracts/protocol/test/utils/match_order_tester.ts index 31864820f..0ba8017c5 100644 --- a/contracts/protocol/test/utils/match_order_tester.ts +++ b/contracts/protocol/test/utils/match_order_tester.ts @@ -66,7 +66,7 @@ export class MatchOrderTester { const feePaidByRightMaker = new BigNumber(rightLog.makerFeePaid); const feePaidByTakerRight = new BigNumber(rightLog.takerFeePaid); // Derive amount received by taker - const amountReceivedByTaker = amountSoldByLeftMaker.sub(amountBoughtByRightMaker); + const amountReceivedByTaker = amountSoldByLeftMaker.minus(amountBoughtByRightMaker); // Assert log values - left order expect(amountBoughtByLeftMaker, 'Checking logged amount bought by left maker').to.be.bignumber.equal( expectedTransferAmounts.amountBoughtByLeftMaker, @@ -267,14 +267,16 @@ export class MatchOrderTester { // Assert left order status const maxAmountBoughtByLeftMaker = signedOrderLeft.takerAssetAmount.minus(initialLeftOrderFilledAmount); const leftOrderInfo: OrderInfo = await this._exchangeWrapper.getOrderInfoAsync(signedOrderLeft); - const leftExpectedStatus = expectedTransferAmounts.amountBoughtByLeftMaker.equals(maxAmountBoughtByLeftMaker) + const leftExpectedStatus = expectedTransferAmounts.amountBoughtByLeftMaker.isEqualTo(maxAmountBoughtByLeftMaker) ? OrderStatus.FullyFilled : OrderStatus.Fillable; expect(leftOrderInfo.orderStatus, 'Checking exchange status for left order').to.be.equal(leftExpectedStatus); // Assert right order status const maxAmountBoughtByRightMaker = signedOrderRight.takerAssetAmount.minus(initialRightOrderFilledAmount); const rightOrderInfo: OrderInfo = await this._exchangeWrapper.getOrderInfoAsync(signedOrderRight); - const rightExpectedStatus = expectedTransferAmounts.amountBoughtByRightMaker.equals(maxAmountBoughtByRightMaker) + const rightExpectedStatus = expectedTransferAmounts.amountBoughtByRightMaker.isEqualTo( + maxAmountBoughtByRightMaker, + ) ? OrderStatus.FullyFilled : OrderStatus.Fillable; expect(rightOrderInfo.orderStatus, 'Checking exchange status for right order').to.be.equal(rightExpectedStatus); @@ -364,13 +366,13 @@ export class MatchOrderTester { // Right Maker expectedNewERC20BalancesByOwner[makerAddressRight][ takerAssetAddressRight - ] = expectedNewERC20BalancesByOwner[makerAddressRight][takerAssetAddressRight].add( + ] = expectedNewERC20BalancesByOwner[makerAddressRight][takerAssetAddressRight].plus( expectedTransferAmounts.amountBoughtByRightMaker, ); // Taker expectedNewERC20BalancesByOwner[takerAddress][makerAssetAddressLeft] = expectedNewERC20BalancesByOwner[ takerAddress - ][makerAssetAddressLeft].add(expectedTransferAmounts.amountReceivedByTaker); + ][makerAssetAddressLeft].plus(expectedTransferAmounts.amountReceivedByTaker); } else if (makerAssetProxyIdLeft === AssetProxyId.ERC721) { // Decode asset data const erc721AssetData = assetDataUtils.decodeERC721AssetData(signedOrderLeft.makerAssetData); @@ -395,7 +397,7 @@ export class MatchOrderTester { // Left Maker expectedNewERC20BalancesByOwner[makerAddressLeft][takerAssetAddressLeft] = expectedNewERC20BalancesByOwner[ makerAddressLeft - ][takerAssetAddressLeft].add(expectedTransferAmounts.amountBoughtByLeftMaker); + ][takerAssetAddressLeft].plus(expectedTransferAmounts.amountBoughtByLeftMaker); // Right Maker expectedNewERC20BalancesByOwner[makerAddressRight][ makerAssetAddressRight @@ -426,19 +428,19 @@ export class MatchOrderTester { expectedNewERC20BalancesByOwner[takerAddress][this._feeTokenAddress] = expectedNewERC20BalancesByOwner[ takerAddress ][this._feeTokenAddress].minus( - expectedTransferAmounts.feePaidByTakerLeft.add(expectedTransferAmounts.feePaidByTakerRight), + expectedTransferAmounts.feePaidByTakerLeft.plus(expectedTransferAmounts.feePaidByTakerRight), ); // Left Fee Recipient Fees expectedNewERC20BalancesByOwner[feeRecipientAddressLeft][ this._feeTokenAddress - ] = expectedNewERC20BalancesByOwner[feeRecipientAddressLeft][this._feeTokenAddress].add( - expectedTransferAmounts.feePaidByLeftMaker.add(expectedTransferAmounts.feePaidByTakerLeft), + ] = expectedNewERC20BalancesByOwner[feeRecipientAddressLeft][this._feeTokenAddress].plus( + expectedTransferAmounts.feePaidByLeftMaker.plus(expectedTransferAmounts.feePaidByTakerLeft), ); // Right Fee Recipient Fees expectedNewERC20BalancesByOwner[feeRecipientAddressRight][ this._feeTokenAddress - ] = expectedNewERC20BalancesByOwner[feeRecipientAddressRight][this._feeTokenAddress].add( - expectedTransferAmounts.feePaidByRightMaker.add(expectedTransferAmounts.feePaidByTakerRight), + ] = expectedNewERC20BalancesByOwner[feeRecipientAddressRight][this._feeTokenAddress].plus( + expectedTransferAmounts.feePaidByRightMaker.plus(expectedTransferAmounts.feePaidByTakerRight), ); return [expectedNewERC20BalancesByOwner, expectedNewERC721TokenIdsByOwner]; |