From ef57bedfadedf3b3d9602ef048e9cbc12f014427 Mon Sep 17 00:00:00 2001 From: Ana Julia Date: Sun, 23 Jun 2024 21:20:18 -0300 Subject: [PATCH] add --ir-minimum to forge coverage --- .github/workflows/ci.yml | 2 +- test/Staking.t.sol | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f07d50a..477982d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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, diff --git a/test/Staking.t.sol b/test/Staking.t.sol index 113bcd0..54f0355 100644 --- a/test/Staking.t.sol +++ b/test/Staking.t.sol @@ -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); + } }