Skip to content

Commit

Permalink
🚨 test: fix function state mutability
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzdanilo committed May 15, 2024
1 parent 129d04e commit ca65672
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions test/DebtPreviewer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/FixedLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/Market.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
10 changes: 5 additions & 5 deletions test/Previewer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion test/PriceFeedPool.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/PriceFeedWrapper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract PriceFeedWrapperTest is Test {
);
}

function testPriceFeedWrapperReturningPrice() external {
function testPriceFeedWrapperReturningPrice() external view {
assertEq(priceFeedWrapper.latestAnswer(), 1079818692742898422);
}

Expand Down
2 changes: 1 addition & 1 deletion test/Protocol.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion test/VotePreviewer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ca65672

Please sign in to comment.