Skip to content

Commit

Permalink
testForkFuzz_MultipleDepositorsStakeMinStakeSameTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
anajuliabit committed Aug 25, 2024
1 parent 1dc2c30 commit 14b0df6
Showing 1 changed file with 44 additions and 49 deletions.
93 changes: 44 additions & 49 deletions test/Staking.integration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -261,53 +261,48 @@ contract StakingIntegrationTest is Test {
assertApproxEqAbs(APR, 21e18, 1e18);
}

// function testForkFuzz_MultipleDepositorsStakeMinStakeSameTimestamp(
// uint256 _depositorsCount,
// uint256 _jump
// ) public {
// _depositorsCount = bound(_depositorsCount, 1, 1000);
//
// _jump = _boundRealisticTimeAhead(_jump);
//
// _setRewardAndFund();
//
// for (uint256 i = 0; i < _depositorsCount; i++) {
// address depositor = address(
// uint160(uint256(keccak256(abi.encodePacked(i))))
// );
// vm.prank(CONTRACT_OWNER);
// staking.setKeyper(depositor, true);
//
// deal(STAKING_TOKEN, depositor, MIN_STAKE);
//
// vm.startPrank(depositor);
// IERC20(STAKING_TOKEN).approve(address(staking), MIN_STAKE);
// staking.stake(MIN_STAKE);
// vm.stopPrank();
// }
//
// uint256 expectedRewardsDistributed = REWARD_RATE * _jump;
//
// uint256 deadAssetsBefore = staking.convertToAssets(
// staking.balanceOf(address(staking))
// );
//
// // uint256 deadRewards = _previewWithdrawIncludeRewardsDistributed()
//
// uint256 expectedRewardPerKeyper = (expectedRewardsDistributed -
// deadAssets) / _depositorsCount;
//
// _jumpAhead(_jump);
//
// for (uint256 i = 0; i < _depositorsCount; i++) {
// address depositor = address(
// uint160(uint256(keccak256(abi.encodePacked(i))))
// );
// vm.startPrank(depositor);
// uint256 rewards = staking.claimRewards(0);
// vm.stopPrank();
//
// assertApproxEqAbs(rewards, expectedRewardPerKeyper, 0.1e18);
// }
// }
function testForkFuzz_MultipleDepositorsStakeMinStakeSameTimestamp(
uint256 _depositorsCount,
uint256 _jump
) public {
_depositorsCount = bound(_depositorsCount, 1, 1000);

_jump = _boundRealisticTimeAhead(_jump);

_setRewardAndFund();

for (uint256 i = 0; i < _depositorsCount; i++) {
address depositor = address(
uint160(uint256(keccak256(abi.encodePacked(i))))
);
vm.prank(CONTRACT_OWNER);
staking.setKeyper(depositor, true);

deal(STAKING_TOKEN, depositor, MIN_STAKE);

vm.startPrank(depositor);
IERC20(STAKING_TOKEN).approve(address(staking), MIN_STAKE);
staking.stake(MIN_STAKE);
vm.stopPrank();
}

_jumpAhead(_jump);

uint256 rewardsPreviousKeyper = 0;

for (uint256 i = 0; i < _depositorsCount; i++) {
address depositor = address(
uint160(uint256(keccak256(abi.encodePacked(i))))
);
vm.startPrank(depositor);
uint256 rewards = staking.claimRewards(0);
vm.stopPrank();

if (i > 0) {
assertApproxEqAbs(rewards, rewardsPreviousKeyper, 0.1e18);
}

rewardsPreviousKeyper = rewards;
}
}
}

0 comments on commit 14b0df6

Please sign in to comment.