Skip to content

Commit

Permalink
skip IntegrationTests from coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
anajuliabit committed Aug 3, 2024
1 parent cccbe73 commit 907887e
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ jobs:
)" >> $GITHUB_ENV
- name: Run coverage
run: forge coverage --report summary --report lcov --ir-minimum
run: forge coverage --report summary --report lcov --ir-minimum \
--nmc IntegrationTest

# 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
80 changes: 80 additions & 0 deletions test/DelegateStaking.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -711,4 +711,84 @@ contract Stake is DelegateStakingTest {
"Alice earn more than Bob after the attack"
);
}

function testFuzz_KeyperCanDelegateToHimself(
address _keyper,
uint256 _amount
) public {
_amount = _boundToRealisticStake(_amount);

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

uint256 stakeId = _stake(_keyper, _keyper, _amount);

(address keyper, , , ) = delegate.stakes(stakeId);

assertEq(keyper, _keyper, "Wrong keyper");
}
}

contract ClaimRewards is DelegateStakingTest {
function testFuzz_UpdateStakerGovTokenBalanceWhenClaimingRewards(
address _keyper,
address _depositor,
uint256 _amount,
uint256 _jump
) public {
_amount = _boundToRealisticStake(_amount);
_jump = _boundRealisticTimeAhead(_jump);

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

uint256 stakeId = _stake(_depositor, _keyper, _amount);

_jumpAhead(_jump);

vm.startPrank(_depositor);
uint256 rewards = delegate.claimRewards(0);

uint256 expectedRewards = REWARD_RATE * (_jump);

// need to accept a small error due to the donation attack prevention
assertApproxEqAbs(
govToken.balanceOf(_depositor),
expectedRewards,
1e18,
"Wrong balance"
);
}

function testFuzz_GovTokenBalanceUnchangedWhenClaimingRewardsOnlyStaker(
address _keyper,
address _depositor,
uint256 _amount,
uint256 _jump
) public {
_amount = _boundToRealisticStake(_amount);
_jump = _boundRealisticTimeAhead(_jump);

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

_stake(_depositor, _keyper, _amount);

uint256 contractBalanceBefore = govToken.balanceOf(address(delegate));

_jumpAhead(_jump);

vm.prank(_depositor);
delegate.claimRewards(0);

uint256 contractBalanceAfter = govToken.balanceOf(address(delegate));

// small percentage lost to the vault due to the donation attack prevention
assertApproxEqAbs(
contractBalanceAfter - contractBalanceBefore,
0,
1e18,
"Wrong balance"
);
}
}

0 comments on commit 907887e

Please sign in to comment.