Skip to content

Commit

Permalink
feat(StakeManager): add test for executing account with limit
Browse files Browse the repository at this point in the history
  • Loading branch information
3esmit committed Sep 11, 2024
1 parent b312c59 commit afe08a1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/StakeManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,25 @@ contract ExecuteAccountTest is StakeManagerTest {
stakeManager.executeAccount(address(userVault), currentEpoch + 1);
}

//Stake, pass epoch, execute epoch, passEpoch, executeEpoch, executeAccount, verify amount of MPs, totalMPs, etc.
function test_ExecuteAccountLimit() public {
uint256 stakeAmount = 10_000_000;
deal(stakeToken, testUser, stakeAmount);
userVaults.push(_createStakingAccount(makeAddr("testUser"), stakeAmount, 0));

(,,, uint256 totalMP, uint256 lastMint,, uint256 epoch,) = stakeManager.accounts(address(userVaults[0]));
vm.warp(stakeManager.epochEnd());
stakeManager.executeEpoch();
vm.warp(stakeManager.epochEnd());

//expected MP is, the starting totalMP + the calculatedMPToMint of user balance for one EPOCH_SIZE multiplied by 2.
uint256 expectedMP = totalMP + (stakeManager.calculateMPToMint(stakeAmount, stakeManager.EPOCH_SIZE())*2);
stakeManager.executeAccount(address(userVaults[0]), stakeManager.currentEpoch() + 1);
(,,, totalMP, lastMint,, epoch,) = stakeManager.accounts(address(userVaults[0]));

assertEq(totalMP, expectedMP, "totalMP is not what the contract itself predicted");
}

function test_ExecuteAccountMintMP() public {
uint256 stakeAmount = 10_000_000;
deal(stakeToken, testUser, stakeAmount);
Expand Down

0 comments on commit afe08a1

Please sign in to comment.