Skip to content

Commit

Permalink
test: gulp fuzzing
Browse files Browse the repository at this point in the history
  • Loading branch information
haythemsellami committed Jul 5, 2024
1 parent 59c4590 commit 85a99db
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions test/fuzz/GulpFuzzTest.t.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {
EulerAggregationVaultBase,
EulerAggregationVault,
IEulerAggregationVault
} from "../common/EulerAggregationVaultBase.t.sol";
import {EulerAggregationVaultBase, EulerAggregationVault} from "../common/EulerAggregationVaultBase.t.sol";

contract GulpFuzzTest is EulerAggregationVaultBase {
function setUp() public virtual override {
Expand All @@ -15,11 +11,9 @@ contract GulpFuzzTest is EulerAggregationVaultBase {
_addStrategy(manager, address(eTST), initialStrategyAllocationPoints);
}

function testFuzz_interestAccrued_under_uint168(
uint256 _interestAmount,
uint256 _depositAmount,
uint256 _timePassed
) public {
function testFuzzInterestAccruedUnderUint168(uint256 _interestAmount, uint256 _depositAmount, uint256 _timePassed)
public
{
_depositAmount = bound(_depositAmount, 0, type(uint112).max);
// this makes sure that the mint won't cause overflow in token accounting
_interestAmount = bound(_interestAmount, 0, type(uint112).max - _depositAmount);
Expand All @@ -41,7 +35,7 @@ contract GulpFuzzTest is EulerAggregationVaultBase {
}

// this tests shows that when you have a very small deposit and a very large interestAmount minted to the contract
function testFuzz_gulp_under_uint168(uint256 _interestAmount, uint256 _depositAmount) public {
function testFuzzGulpUnderUint168(uint256 _interestAmount, uint256 _depositAmount) public {
_depositAmount = bound(_depositAmount, 1e7, type(uint112).max);
_interestAmount = bound(_interestAmount, 0, type(uint256).max - _depositAmount); // this makes sure that the mint won't cause overflow

Expand All @@ -64,4 +58,24 @@ contract GulpFuzzTest is EulerAggregationVaultBase {
assertEq(aggregationVaultSavingRate.interestLeft, type(uint168).max);
}
}

function testFuzzGulpBelowMinSharesForGulp() public {
uint256 depositAmount = 1337;
assetTST.mint(user1, depositAmount);
vm.startPrank(user1);
assetTST.approve(address(eulerAggregationVault), depositAmount);
eulerAggregationVault.deposit(depositAmount, user1);
vm.stopPrank();

uint256 interestAmount = 10e18;
// Mint interest directly into the contract
assetTST.mint(address(eulerAggregationVault), interestAmount);
eulerAggregationVault.gulp();
skip(eulerAggregationVault.INTEREST_SMEAR());

EulerAggregationVault.AggregationVaultSavingRate memory aggregationVaultSavingRate =
eulerAggregationVault.getAggregationVaultSavingRate();
assertEq(eulerAggregationVault.totalAssets(), depositAmount);
assertEq(aggregationVaultSavingRate.interestLeft, 0);
}
}

0 comments on commit 85a99db

Please sign in to comment.