Skip to content

Commit 87a6d76

Browse files
authored
fix: Fix test/scenarios/ynEIGEN/Delegation.t.sol tests (#219)
* fix: Fix delegation tests * fix: Rename to token staking node * fix: Update actors
1 parent b54ad39 commit 87a6d76

File tree

2 files changed

+38
-27
lines changed

2 files changed

+38
-27
lines changed

script/Actors.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ contract ActorAddresses {
1515
address FEE_RECEIVER;
1616
address ORACLE_ADMIN;
1717
address STAKING_NODES_DELEGATOR;
18+
address TOKEN_STAKING_NODES_DELEGATOR;
1819
address UNPAUSE_ADMIN;
1920
address ASSET_MANAGER;
2021
address EIGEN_STRATEGY_ADMIN;
@@ -88,6 +89,7 @@ contract ActorAddresses {
8889
FEE_RECEIVER: holeskyWallets.YNSecurityCouncil,
8990
ORACLE_ADMIN: holeskyWallets.YNSecurityCouncil,
9091
STAKING_NODES_DELEGATOR: holeskyWallets.YNDelegator,
92+
TOKEN_STAKING_NODES_DELEGATOR: holeskyWallets.YNDelegator,
9193
UNPAUSE_ADMIN: holeskyWallets.YNSecurityCouncil,
9294
ASSET_MANAGER: holeskyWallets.YNSecurityCouncil,
9395
EIGEN_STRATEGY_ADMIN: holeskyWallets.YNSecurityCouncil
@@ -140,6 +142,7 @@ contract ActorAddresses {
140142
FEE_RECEIVER: mainnetWallets.YNSecurityCouncil,
141143
ORACLE_ADMIN: mainnetWallets.YNSecurityCouncil,
142144
STAKING_NODES_DELEGATOR: mainnetWallets.YNDelegator,
145+
TOKEN_STAKING_NODES_DELEGATOR: mainnetWallets.YNDelegator,
143146
UNPAUSE_ADMIN: mainnetWallets.YNSecurityCouncil,
144147
ASSET_MANAGER: mainnetWallets.YNSecurityCouncil,
145148
EIGEN_STRATEGY_ADMIN: mainnetWallets.YNSecurityCouncil

test/scenarios/ynEIGEN/Delegation.t.sol

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
pragma solidity ^0.8.24;
33

44
import {IStrategy} from "lib/eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol";
5+
import {IDelegationManagerTypes} from "lib/eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol";
6+
import {ISignatureUtils} from "lib/eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol";
57
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
6-
import {
7-
TransparentUpgradeableProxy,
8-
ITransparentUpgradeableProxy
9-
} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
8+
import {TransparentUpgradeableProxy,ITransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
109
import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
1110

1211
import {ITokenStakingNodesManager} from "src/interfaces/ITokenStakingNodesManager.sol";
@@ -20,45 +19,55 @@ import {WithdrawalQueueManager} from "src/WithdrawalQueueManager.sol";
2019
import {IWithdrawalQueueManager} from "src/interfaces/IWithdrawalQueueManager.sol";
2120
import {IwstETH} from "src/external/lido/IwstETH.sol";
2221
import {IDelegationManagerExtended} from "src/external/eigenlayer/IDelegationManagerExtended.sol";
23-
import {IDelegationManagerTypes} from "lib/eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol";
2422

2523
import "./ynLSDeScenarioBaseTest.sol";
2624

2725
contract YnEigenDelegationScenarioTest is ynLSDeScenarioBaseTest {
26+
ITokenStakingNode internal tokenStakingNode;
27+
28+
function setUp() public override {
29+
super.setUp();
2830

29-
function test_undelegate_Scenario_undelegateByOperator1() public {
3031
updateTokenStakingNodesBalancesForAllAssets();
3132

33+
vm.prank(actors.ops.TOKEN_STAKING_NODE_OPERATOR);
34+
delegationManager.registerAsOperator(address(0), 0, "ipfs://some-ipfs-hash");
35+
36+
tokenStakingNode = tokenStakingNodesManager.nodes(0);
37+
38+
vm.prank(actors.admin.TOKEN_STAKING_NODES_DELEGATOR);
39+
tokenStakingNode.delegate(actors.ops.TOKEN_STAKING_NODE_OPERATOR, ISignatureUtils.SignatureWithExpiry({signature: "", expiry: 0}), bytes32(0));
40+
}
41+
42+
function test_undelegate_Scenario_undelegateByOperator1() public {
3243
// Log total assets before undelegation
3344
uint256 totalAssetsBefore = yneigen.totalAssets();
3445

35-
ITokenStakingNode stakingNode = tokenStakingNodesManager.nodes(0);
36-
3746
// Get operator for node 0
38-
address operator = delegationManager.delegatedTo(address(stakingNode));
47+
address operator = delegationManager.delegatedTo(address(tokenStakingNode));
3948

4049
uint32 blockNumberBefore = uint32(block.number);
41-
uint256 nonceBefore = delegationManager.cumulativeWithdrawalsQueued(address(stakingNode));
50+
uint256 nonceBefore = delegationManager.cumulativeWithdrawalsQueued(address(tokenStakingNode));
4251

4352
// Get strategies and shares before undelegating
44-
(IStrategy[] memory strategies,) = delegationManager.getDepositedShares(address(stakingNode));
45-
(uint256[] memory shares,) = delegationManager.getWithdrawableShares(address(stakingNode), strategies);
53+
(IStrategy[] memory strategies,) = delegationManager.getDepositedShares(address(tokenStakingNode));
54+
(uint256[] memory shares,) = delegationManager.getWithdrawableShares(address(tokenStakingNode), strategies);
4655

4756
uint256[] memory queuedSharesBefore = new uint256[](strategies.length);
4857
for (uint256 i = 0; i < strategies.length; i++) {
49-
queuedSharesBefore[i] = stakingNode.queuedShares(strategies[i]);
58+
queuedSharesBefore[i] = tokenStakingNode.queuedShares(strategies[i]);
5059
}
5160

5261
// Call undelegate from operator
5362
vm.startPrank(operator);
54-
bytes32[] memory withdrawalRoots = delegationManager.undelegate(address(stakingNode));
63+
bytes32[] memory withdrawalRoots = delegationManager.undelegate(address(tokenStakingNode));
5564
vm.stopPrank();
5665

57-
uint256 nonceAfter = delegationManager.cumulativeWithdrawalsQueued(address(stakingNode));
66+
uint256 nonceAfter = delegationManager.cumulativeWithdrawalsQueued(address(tokenStakingNode));
5867

5968
// Assert node is no longer delegated after undelegation
6069
assertEq(
61-
delegationManager.delegatedTo(address(stakingNode)),
70+
delegationManager.delegatedTo(address(tokenStakingNode)),
6271
address(0),
6372
"Node should not be delegated after undelegation"
6473
);
@@ -67,15 +76,15 @@ contract YnEigenDelegationScenarioTest is ynLSDeScenarioBaseTest {
6776
assertEq(totalAssetsBefore, yneigen.totalAssets(), "Total assets should not change after undelegation");
6877

6978
// Assert node is not synchronized after undelegation
70-
assertFalse(stakingNode.isSynchronized(), "Node should not be synchronized after undelegation");
79+
assertFalse(tokenStakingNode.isSynchronized(), "Node should not be synchronized after undelegation");
7180

7281
//Call synchronize after verifying not synchronized
73-
vm.prank(actors.admin.STAKING_NODES_DELEGATOR);
74-
stakingNode.synchronize(shares, blockNumberBefore, strategies);
82+
vm.prank(actors.admin.TOKEN_STAKING_NODES_DELEGATOR);
83+
tokenStakingNode.synchronize(shares, blockNumberBefore, strategies);
7584

7685
for (uint256 i = 0; i < strategies.length; i++) {
7786
assertEq(
78-
stakingNode.queuedShares(strategies[i]) - queuedSharesBefore[i],
87+
tokenStakingNode.queuedShares(strategies[i]) - queuedSharesBefore[i],
7988
shares[i],
8089
"Queued shares should be equal to shares"
8190
);
@@ -93,7 +102,7 @@ contract YnEigenDelegationScenarioTest is ynLSDeScenarioBaseTest {
93102
singleStrategy[0] = strategies[i];
94103
uint256[] memory singleShare = new uint256[](1);
95104
singleShare[0] = shares[i];
96-
address _Staker = address(stakingNode);
105+
address _Staker = address(tokenStakingNode);
97106
withdrawals[i] = IDelegationManagerTypes.Withdrawal({
98107
staker: _Staker,
99108
delegatedTo: operator,
@@ -108,12 +117,12 @@ contract YnEigenDelegationScenarioTest is ynLSDeScenarioBaseTest {
108117
// advance time to allow completion
109118
vm.roll(block.number + delegationManager.minWithdrawalDelayBlocks() + 1);
110119

111-
vm.prank(actors.admin.STAKING_NODES_DELEGATOR);
112-
stakingNode.completeQueuedWithdrawalsAsShares(withdrawals, middlewareTimesIndexes);
120+
vm.prank(actors.admin.TOKEN_STAKING_NODES_DELEGATOR);
121+
tokenStakingNode.completeQueuedWithdrawalsAsShares(withdrawals, middlewareTimesIndexes);
113122

114123
for (uint256 i = 0; i < strategies.length; i++) {
115124
assertEq(
116-
stakingNode.queuedShares(strategies[i]),
125+
tokenStakingNode.queuedShares(strategies[i]),
117126
queuedSharesBefore[i],
118127
"Queued shares should be reinvested after completion of withdrawals"
119128
);
@@ -124,15 +133,14 @@ contract YnEigenDelegationScenarioTest is ynLSDeScenarioBaseTest {
124133
}
125134

126135
function test_undelegate_Scenario_undelegateByDelegator() public {
127-
updateTokenStakingNodesBalancesForAllAssets();
128136
uint256 totalAssetsBefore = yneigen.totalAssets();
129137

130138
ITokenStakingNode tokenStakingNode = tokenStakingNodesManager.nodes(0);
131139

132140
uint256 undelegateBlockNumber = uint32(block.number);
133141

134142
// Call undelegate from delegator
135-
vm.startPrank(actors.admin.STAKING_NODES_DELEGATOR);
143+
vm.startPrank(actors.admin.TOKEN_STAKING_NODES_DELEGATOR);
136144
tokenStakingNode.undelegate();
137145
vm.stopPrank();
138146

@@ -149,7 +157,7 @@ contract YnEigenDelegationScenarioTest is ynLSDeScenarioBaseTest {
149157

150158
// Call synchronize after verifying synchronized
151159
vm.expectRevert(TokenStakingNode.AlreadySynchronized.selector);
152-
vm.prank(actors.admin.STAKING_NODES_DELEGATOR);
160+
vm.prank(actors.admin.TOKEN_STAKING_NODES_DELEGATOR);
153161
tokenStakingNode.synchronize(new uint256[](0), uint32(block.number), new IStrategy[](0));
154162
}
155163

0 commit comments

Comments
 (0)