From ca656724ff69c96d1a02533c5dec715404abae03 Mon Sep 17 00:00:00 2001 From: danilo neves cruz Date: Wed, 15 May 2024 13:25:29 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20test:=20fix=20function=20state?= =?UTF-8?q?=20mutability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gas-snapshot | 6 +++--- test/DebtPreviewer.t.sol | 16 ++++++++-------- test/FixedLib.t.sol | 2 +- test/Market.t.sol | 2 +- test/Previewer.t.sol | 10 +++++----- test/PriceFeedPool.t.sol | 2 +- test/PriceFeedWrapper.t.sol | 2 +- test/Protocol.t.sol | 2 +- test/VotePreviewer.t.sol | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 3609f83e2..a566e3012 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -136,12 +136,12 @@ InstallmentsRouterTest:testInsufficientMaxRepay() (gas: 630307) InstallmentsRouterTest:testMaxRepay() (gas: 630294) InstallmentsRouterTest:testMissingMarketWETH() (gas: 776941) InstallmentsRouterTest:testMoreBorrowsThanMaxPools() (gas: 634146) -InterestRateModelTest:testFixedBorrowRate() (gas: 2063742) +InterestRateModelTest:testFixedBorrowRate() (gas: 2063720) InterestRateModelTest:testFixedRateRevertAlreadyMatured() (gas: 2057902) InterestRateModelTest:testFixedRateRevertUtilizationExceeded() (gas: 2065065) InterestRateModelTest:testFloatingBorrowRate() (gas: 2057206) -InterestRateModelTest:testMinTimeToMaturity() (gas: 2075242) -InterestRateModelTest:testRevertMaxUtilizationLowerThanWad() (gas: 267435) +InterestRateModelTest:testMinTimeToMaturity() (gas: 2075220) +InterestRateModelTest:testRevertMaxUtilizationLowerThanWad() (gas: 267545) MarketTest:testAccountLiquidityAdjustedDebt() (gas: 499481) MarketTest:testAnotherUserRedeemWhenOwnerHasShortfall() (gas: 819094) MarketTest:testAnotherUserWithdrawWhenOwnerHasShortfall() (gas: 806786) diff --git a/test/DebtPreviewer.t.sol b/test/DebtPreviewer.t.sol index 80a7fa14e..6bf40e1fe 100644 --- a/test/DebtPreviewer.t.sol +++ b/test/DebtPreviewer.t.sol @@ -90,7 +90,7 @@ contract DebtPreviewerTest is ForkTest { ); } - function testPreviewEmptyLeverage() external { + function testPreviewEmptyLeverage() external view { Leverage memory leverage = debtPreviewer.leverage(marketUSDC, marketUSDC, address(this), 1e18); (uint256 collateralAdjustFactor, , , , ) = auditor.markets(marketUSDC); (uint256 debtAdjustFactor, , , , ) = auditor.markets(marketUSDC); @@ -178,7 +178,7 @@ contract DebtPreviewerTest is ForkTest { assertApproxEqAbs(limit.borrow, marketWETH.previewRefund(floatingBorrowShares), 2); } - function testPreviewLeverageBalancerAvailableLiquidity() external { + function testPreviewLeverageBalancerAvailableLiquidity() external view { Leverage memory leverage = debtPreviewer.leverage(marketUSDC, marketUSDC, address(this), 1e18); Market[] memory markets = auditor.allMarkets(); assertEq(leverage.availableAssets.length, markets.length); @@ -279,7 +279,7 @@ contract DebtPreviewerTest is ForkTest { assertApproxEqAbs(coll.divWadDown(debt), 1e18, 5e7); } - function testLeverageRatesCrossAsset() external { + function testLeverageRatesCrossAsset() external view { uint256 depositRate = 1.91e16; Rates memory rates = debtPreviewer.leverageRates( marketUSDC, @@ -308,7 +308,7 @@ contract DebtPreviewerTest is ForkTest { assertEq(rates.rewards[1].borrow, 37023661655907600); } - function testLeverageRatesSameAsset() external { + function testLeverageRatesSameAsset() external view { uint256 depositRate = 1.91e16; Rates memory rates = debtPreviewer.leverageRates( marketUSDC, @@ -349,7 +349,7 @@ contract DebtPreviewerTest is ForkTest { assertEq(rates.rewards[0].deposit, 48615737527381200); } - function testLeverageRatesZeroPrincipalCrossAsset() external { + function testLeverageRatesZeroPrincipalCrossAsset() external view { uint256 depositRate = 1.91e16; Rates memory rates = debtPreviewer.leverageRates(marketUSDC, marketWETH, address(this), 0, 2e18, depositRate, 0, 0); @@ -370,7 +370,7 @@ contract DebtPreviewerTest is ForkTest { assertEq(rates.rewards[1].borrow, 18511830827953800); } - function testLeverageRatesZeroPrincipalSameAsset() external { + function testLeverageRatesZeroPrincipalSameAsset() external view { uint256 depositRate = 1.91e16; Rates memory rates = debtPreviewer.leverageRates(marketUSDC, marketUSDC, address(this), 0, 2e18, depositRate, 0, 0); @@ -386,7 +386,7 @@ contract DebtPreviewerTest is ForkTest { assertEq(rates.rewards[0].borrow, 17486201807999040); } - function testLeverageRatesWithNativeBorrow() external { + function testLeverageRatesWithNativeBorrow() external view { uint256 nativeRateBorrow = 3.9e18; uint256 depositRate = 1.9e18; uint256 nativeRate = 3.9e18; @@ -406,7 +406,7 @@ contract DebtPreviewerTest is ForkTest { assertEq(rates.native, int256(nativeRate.mulWadDown(ratio) - nativeRateBorrow.mulWadDown(ratio - 1e18)), "native"); } - function testLeverageRatesWithNegativeNativeResult() external { + function testLeverageRatesWithNegativeNativeResult() external view { uint256 nativeRateBorrow = 3.9e18; uint256 depositRate = 1.9e18; uint256 nativeRate = 0; diff --git a/test/FixedLib.t.sol b/test/FixedLib.t.sol index 8c2f3e7cf..f7f382220 100644 --- a/test/FixedLib.t.sol +++ b/test/FixedLib.t.sol @@ -67,7 +67,7 @@ contract PoolLibTest is Test { assertEq(treasury, 1 ether); } - function testMaturityRangeLimit() external { + function testMaturityRangeLimit() external pure { uint256 maturities; maturities = maturities.setMaturity(FixedLib.INTERVAL); maturities = maturities.setMaturity(FixedLib.INTERVAL * 224); diff --git a/test/Market.t.sol b/test/Market.t.sol index b7decde24..9b7546ff3 100644 --- a/test/Market.t.sol +++ b/test/Market.t.sol @@ -2714,7 +2714,7 @@ contract MarketTest is Test { assertTrue(market.hasRole(market.PAUSER_ROLE(), address(this))); } - function testInitiallyUnfrozen() external { + function testInitiallyUnfrozen() external view { assertFalse(market.isFrozen()); } diff --git a/test/Previewer.t.sol b/test/Previewer.t.sol index 612982552..1164b24fc 100644 --- a/test/Previewer.t.sol +++ b/test/Previewer.t.sol @@ -190,17 +190,17 @@ contract PreviewerTest is Test { assertEq(preview.assets, principalAfterDeposit + earningsAfterDeposit); } - function testPreviewDepositAtMaturityWithEmptyMaturity() external { + function testPreviewDepositAtMaturityWithEmptyMaturity() external view { Previewer.FixedPreview memory preview = previewer.previewDepositAtMaturity(market, FixedLib.INTERVAL, 1 ether); assertEq(preview.assets, 1 ether); } - function testPreviewDepositAtMaturityWithEmptyMaturityAndZeroAmount() external { + function testPreviewDepositAtMaturityWithEmptyMaturityAndZeroAmount() external view { Previewer.FixedPreview memory preview = previewer.previewDepositAtMaturity(market, FixedLib.INTERVAL, 0); assertEq(preview.assets, 0); } - function testPreviewDepositAtMaturityWithInvalidMaturity() external { + function testPreviewDepositAtMaturityWithInvalidMaturity() external view { Previewer.FixedPreview memory preview = previewer.previewDepositAtMaturity(market, 376 seconds, 1 ether); assertEq(preview.assets, 1 ether); } @@ -1499,7 +1499,7 @@ contract PreviewerTest is Test { } } - function testExactlyReturningInterestRateModelData() external { + function testExactlyReturningInterestRateModelData() external view { Previewer.MarketAccount[] memory data = previewer.exactly(address(this)); assertEq(data[0].interestRateModel.id, address(irm)); @@ -2168,7 +2168,7 @@ contract PreviewerTest is Test { ); } - function testAccountsWithEmptyAccount() external { + function testAccountsWithEmptyAccount() external view { Previewer.MarketAccount[] memory data = previewer.exactly(address(this)); assertEq(data[0].symbol, market.symbol()); diff --git a/test/PriceFeedPool.t.sol b/test/PriceFeedPool.t.sol index 18afb95da..cbed3a922 100644 --- a/test/PriceFeedPool.t.sol +++ b/test/PriceFeedPool.t.sol @@ -20,7 +20,7 @@ contract PriceFeedPoolTest is Test { priceFeedPool = new PriceFeedPool(mockPool, ethPriceFeed, false); } - function testPriceFeedPoolReturningPrice() external { + function testPriceFeedPoolReturningPrice() external view { (uint256 reserve0, uint256 reserve1, ) = mockPool.getReserves(); uint256 usdPrice = uint256(ethPriceFeed.latestAnswer()).mulDivDown(reserve0, reserve1); assertEq(usdPrice, 400e18); diff --git a/test/PriceFeedWrapper.t.sol b/test/PriceFeedWrapper.t.sol index ee5d21819..f7ce3a108 100644 --- a/test/PriceFeedWrapper.t.sol +++ b/test/PriceFeedWrapper.t.sol @@ -26,7 +26,7 @@ contract PriceFeedWrapperTest is Test { ); } - function testPriceFeedWrapperReturningPrice() external { + function testPriceFeedWrapperReturningPrice() external view { assertEq(priceFeedWrapper.latestAnswer(), 1079818692742898422); } diff --git a/test/Protocol.t.sol b/test/Protocol.t.sol index 73c0f9c19..ef116863e 100644 --- a/test/Protocol.t.sol +++ b/test/Protocol.t.sol @@ -628,7 +628,7 @@ contract ProtocolTest is Test { } } - function checkInvariants() internal { + function checkInvariants() internal view { uint256 claimedRewards; for (uint256 i = 0; i < accounts.length; ++i) { address account = accounts[i]; diff --git a/test/VotePreviewer.t.sol b/test/VotePreviewer.t.sol index 56563091c..72fb002ba 100644 --- a/test/VotePreviewer.t.sol +++ b/test/VotePreviewer.t.sol @@ -34,7 +34,7 @@ contract VotePreviewerTest is ForkTest { vm.label(address(previewer), "VotePreviewer"); } - function testExternalVotes() external { + function testExternalVotes() external view { assertEq(previewer.externalVotes(0x23fD464e0b0eE21cEdEb929B19CABF9bD5215019), 27401932247383718289362); assertEq(previewer.externalVotes(0x1283D47A121f903D9BD73f0f8E83728c488969f5), 1559177426053281144); assertEq(previewer.externalVotes(0x4cd45E3Fef61079Ee67cbB9e9e230641A4Ae2f87), 368157682632212466);