Skip to content

Commit

Permalink
add test coverage for deposit(amount)
Browse files Browse the repository at this point in the history
  • Loading branch information
jac18281828 committed May 2, 2024
1 parent f5b09ff commit 6418d52
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions test/StaderHavenStakingManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ contract StaderHavenStakingManagerTest is Test {
//Starting with ETHx/ETH ER as 1:1, will increase it to see the impact on hsETH to ETH ER (should be less than
// latest ETHx ER).
function testDepositWithZeroInitialSupplyOfETHx(uint64 amount) external {
vm.assume(amount > 0.1 ether && amount < 100 ether);
vm.assume(amount > staderConfig.getMinWithdrawAmount() && amount < 100 ether);
address user = vm.addr(0x101);
vm.deal(user, 5 * uint256(amount));

Expand Down Expand Up @@ -169,23 +169,32 @@ contract StaderHavenStakingManagerTest is Test {
);
}

function testDepositWithMinimumTokenRequirement() external {
function testDepositWithMinimumTokenRequirementNotMet() external {
uint256 amount = 1 ether;
address user = vm.addr(0x101);
vm.deal(user, 5 * amount);
vm.deal(user, amount);
vm.expectRevert(
abi.encodeWithSelector(IStaderHavenStakingManager.MinimumHsETHNotMet.selector, amount + 1 gwei, amount)
);
vm.startPrank(user);
vm.prank(user);
staderHavenStakingManager.deposit{ value: amount }(amount + 1 gwei);
vm.stopPrank();
}

function testDepositWithMinimumTokenRequirement() external {
uint256 amount = 1 ether;
address user = vm.addr(0x101);
vm.deal(user, amount);
vm.prank(user);
staderHavenStakingManager.deposit{ value: amount }(amount);
assertEq(hsETH.balanceOf(user), amount);
assertEq(hsETH.totalSupply(), amount);
}

//Testing unstake along with withdrawing protocol fee to check if any residue ETHx token in the contract.
//This test verifies that there is residue ETHx token in the contract which is fine as rounding is preferring
// protocol.
function testRequestWithdrawWithSingleUser(uint64 amount) external {
vm.assume(amount > 0.1 ether && amount < 100 ether);
vm.assume(amount > staderConfig.getMinWithdrawAmount() && amount < 100 ether);
address user = vm.addr(0x101);
vm.deal(user, 5 * uint256(amount));

Expand Down Expand Up @@ -259,7 +268,7 @@ contract StaderHavenStakingManagerTest is Test {
}

function testRequestWithdrawProtocolFeeEvent(uint64 amount) external {
vm.assume(amount > 0.1 ether && amount < 100 ether);
vm.assume(amount > staderConfig.getMinWithdrawAmount() && amount < 100 ether);
address user = vm.addr(0x101);
vm.deal(user, 5 * uint256(amount));

Expand Down Expand Up @@ -339,7 +348,7 @@ contract StaderHavenStakingManagerTest is Test {
// protocol.
function testRequestWithdrawWithTwoUsers(uint64 randomSeed1, uint64 randomSeed2, uint64 amount) external {
vm.assume(randomSeed1 > 0 && randomSeed2 > 0 && randomSeed1 != randomSeed2);
vm.assume(amount > 0.1 ether && amount < 100 ether);
vm.assume(amount > staderConfig.getMinWithdrawAmount() && amount < 100 ether);
address user = vm.addr(randomSeed1);
address user2 = vm.addr(randomSeed2);
vm.deal(user, 5 * uint256(amount));
Expand Down

0 comments on commit 6418d52

Please sign in to comment.