Skip to content

Commit

Permalink
chore: refactor test_redeem_whenBeforeCliffEndAndFirstRedeem_shouldLo…
Browse files Browse the repository at this point in the history
…ckAll()
  • Loading branch information
philbow61 committed Jan 30, 2024
1 parent 909dd55 commit d61f52d
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions test/vesting/VestingLock.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,18 @@ contract VestingLockTest_redeem is VestingLockTest {
}

function test_redeem_whenBeforeCliffEndAndFirstRedeem_shouldLockAll() public {
uint256 hedgeyRedeemableAmount = 10_000 * 1e18;

uint256 currentWeek = 52;
skipWeeks(currentWeek);

// because currentWeek is pre cliffEndWeek 105
uint32 cliff = uint32(cliffEndWeek - currentWeek);
// full 2 year slope period since currentWeek is pre slopeStart(cliffEndWeek)
uint32 slope = uint32(slopeEndWeek - cliffEndWeek);

mockTokenVestingPlans.setRedeemableTokens(hedgeyRedeemableAmount);
mockLocking.setWeek(currentWeek);
mockLocking.setWithdraw(0, mentoTokenAddr);

vestingLock.initializeVestingPlan();
uint256 planId = vestingLock.planId();
uint256 lockIdBefore = vestingLock.veMentoLockId();
assertEq(lockIdBefore, 0);

vm.prank(beneficiary);
vm.expectCall( // ensure redeemPlans is called with correct parameters
hedgeyVestingAddr,
abi.encodeWithSelector(ITokenVestingPlans.redeemPlans.selector, Arrays.uints(planId))
Expand All @@ -174,14 +167,15 @@ contract VestingLockTest_redeem is VestingLockTest {
MockLockingExtended.lock.selector,
address(vestingLock),
beneficiary,
hedgeyRedeemableAmount,
basicPlan.amount / 4, // 52/208 ~ 1/4
slope,
cliff
)
);
// ensure no tokens are transferred to beneficiary
vm.expectCall(mentoTokenAddr, abi.encodeWithSelector(mentoToken.transfer.selector), 0);

vm.prank(beneficiary);
vestingLock.redeem();

assertEq(mentoToken.balanceOf(beneficiary), 0);
Expand Down

0 comments on commit d61f52d

Please sign in to comment.