Skip to content

Commit

Permalink
add testFuzz_RevertIf_UnstakeResultsInBalanceLowerThanMinStaked
Browse files Browse the repository at this point in the history
  • Loading branch information
anajuliabit committed Jul 2, 2024
1 parent 353b9a4 commit 4ab7395
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/Staking.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,37 @@ contract Unstake is StakingTest {
staking.unstake(_depositor, stakeId, 0);
}

function testFuzz_RevertIf_UnstakeResultsInBalanceLowerThanMinStaked(
address _depositor
) public {
vm.assume(
_depositor != address(0) &&
_depositor != ProxyUtils.getAdminAddress(address(staking))
);

// create multiple users staking to make the rewards amount accumulated
// for _depositor not greater enough to withdraw the min stake
for (uint256 i = 0; i < 50; i++) {
address user = address(
uint160(uint256(keccak256(abi.encodePacked(i))))
);
_mintGovToken(user, MIN_STAKE);
_setKeyper(user, true);
_stake(user, MIN_STAKE);
}

_mintGovToken(_depositor, MIN_STAKE);
_setKeyper(_depositor, true);

uint256 stakeId = _stake(_depositor, MIN_STAKE);

_jumpAhead(vm.getBlockTimestamp() + LOCK_PERIOD);

vm.prank(_depositor);
vm.expectRevert(Staking.WithdrawAmountTooHigh.selector);
staking.unstake(_depositor, stakeId, MIN_STAKE);
}

function testFuzz_RevertIf_StakeDoesNotBelongToKeyper(
address _depositor1,
address _depositor2,
Expand Down

0 comments on commit 4ab7395

Please sign in to comment.