mirror of https://github.com/logos-co/staking.git
test(StakeManager): honor lockup period when unstaking
This adds a test to check that the lockup period is considered when a user tries to unstake their funds through their vault.
This commit is contained in:
parent
4e411f2b37
commit
300a296137
|
@ -283,4 +283,29 @@ contract UserFlowsTest is StakeManagerTest {
|
||||||
assertEq(ERC20(stakeToken).balanceOf(address(user2Vault)), 0);
|
assertEq(ERC20(stakeToken).balanceOf(address(user2Vault)), 0);
|
||||||
assertEq(stakeManager.stakeSupply(), 0);
|
assertEq(stakeManager.stakeSupply(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_StakeWithLockUpTimeLocksStake() public {
|
||||||
|
// ensure users have funds
|
||||||
|
deal(stakeToken, testUser, 1000);
|
||||||
|
|
||||||
|
StakeVault userVault = _createTestVault(testUser);
|
||||||
|
|
||||||
|
vm.startPrank(testUser);
|
||||||
|
// approve user vault to spend user tokens
|
||||||
|
ERC20(stakeToken).approve(address(userVault), 100);
|
||||||
|
|
||||||
|
// stake with lockup time of 12 weeks
|
||||||
|
userVault.stake(100, 12 weeks);
|
||||||
|
|
||||||
|
// unstaking should fail as lockup time isn't over yet
|
||||||
|
vm.expectRevert(StakeManager.StakeManager__FundsLocked.selector);
|
||||||
|
userVault.unstake(100);
|
||||||
|
|
||||||
|
// fast forward 12 weeks
|
||||||
|
skip(12 weeks + 1);
|
||||||
|
|
||||||
|
userVault.unstake(100);
|
||||||
|
assertEq(ERC20(stakeToken).balanceOf(address(userVault)), 0);
|
||||||
|
assertEq(stakeManager.stakeSupply(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue