Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
chg
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Ermolin committed Jan 17, 2022
1 parent fc58f80 commit 2dd5fe5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion contracts/staking/stakeManager/StakeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,14 @@ contract StakeManager is
require(delegationEnabled, "Delegation is disabled");
}

if (validators[validatorId].deactivationEpoch == 0) { // modify timeline only if validator didn't unstake
uint256 deactivationEpoch = validators[validatorId].deactivationEpoch;

if (deactivationEpoch == 0) { // modify timeline only if validator didn't unstake
updateTimeline(amount, 0, 0);
} else if (deactivationEpoch > currentEpoch) { // validator just unstaked, need to wait till next checkpoint
revert("unstaking");
}


if (amount >= 0) {
increaseValidatorDelegatedAmount(validatorId, uint256(amount));
Expand Down
4 changes: 3 additions & 1 deletion test/units/staking/stakeManager/StakeManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2482,7 +2482,9 @@ contract('StakeManager', async function(accounts) {
totalStakeAfterUnstake = await this.stakeManager.currentValidatorSetTotalStake()
})

testMigration()
it('reverts', async function() {
await expectRevert(this.stakeManager.migrateDelegation(aliceId, bobId, delegationAmount, { from: delegator }), 'unstaking');
})
})
})

Expand Down

0 comments on commit 2dd5fe5

Please sign in to comment.