Skip to content

Commit

Permalink
add --ir-minimum to forge coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
anajuliabit committed Jun 24, 2024
1 parent 820fa49 commit ef57bed
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
)" >> $GITHUB_ENV
- name: Run coverage
run: forge coverage --report summary --report lcov
run: forge coverage --report summary --report lcov --ir-minimum

# To ignore coverage for certain directories modify the paths in this step as needed. The
# below default ignores coverage results for the test and script directories. Alternatively,
Expand Down
34 changes: 34 additions & 0 deletions test/Staking.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1073,4 +1073,38 @@ contract Unstake is StakingTest {
vm.expectRevert(Staking.StakeDoesNotBelongToKeyper.selector);
staking.unstake(_depositor2, stakeId, 0);
}

function testFuzz_RevertIf_AmountGreaterThanStakeAmount(
address _depositor,
uint256 _amount
) public {
_amount = _boundToRealisticStake(_amount);

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

uint256 stakeIndex = _stake(_depositor, _amount);

vm.prank(_depositor);
vm.expectRevert(Staking.WithdrawAmountTooHigh.selector);
staking.unstake(_depositor, stakeIndex, _amount + 1);
}

function testFuzz_RevertIf_NonKeyperTryToUnstake(
address _depositor,
address _anyone,
uint256 _amount
) public {
_amount = _boundToRealisticStake(_amount);

_mintGovToken(_depositor, _amount);

_setKeyper(_depositor, true);

uint256 stakeId = _stake(_depositor, _amount);

vm.prank(_anyone);
vm.expectRevert(Staking.OnlyKeyper.selector);
staking.unstake(_depositor, stakeId, 0);
}
}

0 comments on commit ef57bed

Please sign in to comment.