diff --git a/test/DelegateStaking.t.sol b/test/DelegateStaking.t.sol index 2d42109..810f4cd 100644 --- a/test/DelegateStaking.t.sol +++ b/test/DelegateStaking.t.sol @@ -817,36 +817,6 @@ contract ClaimRewards is DelegateStakingTest { delegate.claimRewards(0); } - function testFuzz_ClaimAllRewardsOnlyStaker( - 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); - - _jumpAhead(_jump); - - // first 1000 shares was the dead shares so must decrease from the expected rewards - uint256 assetsAmount = _convertToAssetsIncludeRewardsDistributed( - delegate.balanceOf(_depositor), - REWARD_RATE * _jump - ); - - uint256 expectedRewards = assetsAmount - _amount; - - vm.prank(_depositor); - uint256 rewards = delegate.claimRewards(0); - - assertEq(rewards, expectedRewards, "Wrong rewards"); - } - function testFuzz_ClaimRewardBurnShares( address _keyper, address _depositor, @@ -867,7 +837,7 @@ contract ClaimRewards is DelegateStakingTest { // first 1000 shares was the dead shares so must decrease from the expected rewards uint256 assetsAmount = _convertToAssetsIncludeRewardsDistributed( - staking.balanceOf(_depositor), + delegate.balanceOf(_depositor), REWARD_RATE * _jump ); diff --git a/test/RewardsDistributor.t.sol b/test/RewardsDistributor.t.sol index d25ae86..47b9caf 100644 --- a/test/RewardsDistributor.t.sol +++ b/test/RewardsDistributor.t.sol @@ -103,7 +103,7 @@ contract OwnableFunctions is RewardsDistributorTest { assertEq(lastUpdate, vm.getBlockTimestamp()); } - function testFuzz_DoNotSetLastUpdateIfIsNotTheFirstTime( + function testFuzz_TransferTokensIfIsAnUpdate( address _receiver, uint256 _emissionRate ) public { @@ -116,14 +116,20 @@ contract OwnableFunctions is RewardsDistributorTest { _receiver ); + uint256 balanceBefore = govToken.balanceOf(_receiver); + + govToken.mint(address(rewardsDistributor), _emissionRate); + vm.warp(vm.getBlockTimestamp() + 1); rewardsDistributor.setRewardConfiguration(_receiver, _emissionRate); + assertEq(govToken.balanceOf(_receiver), balanceBefore + _emissionRate); + (, uint256 lastUpdateAfter) = rewardsDistributor.rewardConfigurations( _receiver ); - assertEq(lastUpdateBefore, lastUpdateAfter); + assertEq(lastUpdateBefore + 1, lastUpdateAfter); } function testFuzz_RevertIf_SetRewardConfigurationZeroAddress( @@ -240,18 +246,18 @@ contract OwnableFunctions is RewardsDistributorTest { ) public { vm.assume(_anyone != address(this)); + govToken.mint(address(rewardsDistributor), _amount); + + address token = address(rewardsDistributor.rewardToken()); vm.expectRevert( abi.encodeWithSelector( Ownable.OwnableUnauthorizedAccount.selector, _anyone ) ); + vm.prank(_anyone); - rewardsDistributor.withdrawFunds( - address(rewardsDistributor.rewardToken()), - _to, - _amount - ); + rewardsDistributor.withdrawFunds(token, _to, _amount); } } diff --git a/test/Staking.t.sol b/test/Staking.t.sol index ea93ef0..81b7e94 100644 --- a/test/Staking.t.sol +++ b/test/Staking.t.sol @@ -810,33 +810,6 @@ contract ClaimRewards is StakingTest { staking.claimRewards(0); } - function testFuzz_ClaimAllRewardsOnlyStaker( - address _depositor, - uint256 _amount, - uint256 _jump - ) public { - _amount = _boundToRealisticStake(_amount); - _jump = _boundRealisticTimeAhead(_jump); - - _mintGovToken(_depositor, _amount); - _setKeyper(_depositor, true); - - _stake(_depositor, _amount); - - uint256 timestampBefore = vm.getBlockTimestamp(); - - _jumpAhead(_jump); - - vm.prank(_depositor); - uint256 rewards = staking.claimRewards(0); - - uint256 expectedRewards = REWARD_RATE * - (vm.getBlockTimestamp() - timestampBefore); - - // need to accept a small error due to the donation attack prevention - assertApproxEqAbs(rewards, expectedRewards, 1e18, "Wrong rewards"); - } - function testFuzz_ClaimRewardBurnShares( address _depositor, uint256 _amount,