Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Failing Integration Tests #384

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/test/integration/IntegrationChecks.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ contract IntegrationCheckUtils is IntegrationBase {
// ... check that each withdrawal was successfully enqueued, that the returned roots
// match the hashes of each withdrawal, and that the staker and operator have
// reduced shares.
assertEq(withdrawalRoots.length, 1, "check_QueuedWithdrawal_State: should only have 1 withdrawal root after queueing");
assert_AllWithdrawalsPending(withdrawalRoots,
"check_QueuedWithdrawal_State: staker withdrawals should now be pending");
assert_ValidWithdrawalHashes(withdrawals, withdrawalRoots,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ contract Integration_Deposit_Delegate_Redelegate_Complete is IntegrationCheckUti
// 4. Complete withdrawal as shares
// Fast forward to when we can complete the withdrawal
cheats.roll(block.number + delegationManager.withdrawalDelayBlocks());
staker.completeWithdrawalAsShares(withdrawals[0]);

check_Withdrawal_AsShares_Undelegated_State(staker, operator1, withdrawals[0], strategies, shares);
for (uint256 i = 0; i < withdrawals.length; ++i) {
staker.completeWithdrawalAsShares(withdrawals[i]);
check_Withdrawal_AsShares_Undelegated_State(staker, operator1, withdrawals[i], withdrawals[i].strategies, withdrawals[i].shares);
}

// 5. Delegate to a new operator
staker.delegateTo(operator2);
Expand Down Expand Up @@ -207,8 +208,10 @@ contract Integration_Deposit_Delegate_Redelegate_Complete is IntegrationCheckUti
// 4. Complete withdrawal as shares
// Fast forward to when we can complete the withdrawal
cheats.roll(block.number + delegationManager.withdrawalDelayBlocks());
staker.completeWithdrawalAsShares(withdrawals[0]);
check_Withdrawal_AsShares_Undelegated_State(staker, operator1, withdrawals[0], strategies, halfShares);
for (uint256 i = 0; i < withdrawals.length; ++i) {
staker.completeWithdrawalAsShares(withdrawals[i]);
check_Withdrawal_AsShares_Undelegated_State(staker, operator1, withdrawals[i], withdrawals[i].strategies, withdrawals[i].shares);
}

// 5. Delegate to a new operator
staker.delegateTo(operator2);
Expand Down Expand Up @@ -292,8 +295,10 @@ contract Integration_Deposit_Delegate_Redelegate_Complete is IntegrationCheckUti
// 4. Complete withdrawal as shares
// Fast forward to when we can complete the withdrawal
cheats.roll(block.number + delegationManager.withdrawalDelayBlocks());
staker.completeWithdrawalAsShares(withdrawals[0]);
check_Withdrawal_AsShares_Undelegated_State(staker, operator1, withdrawals[0], strategies, halfShares);
for (uint256 i = 0; i < withdrawals.length; ++i) {
staker.completeWithdrawalAsShares(withdrawals[i]);
check_Withdrawal_AsShares_Undelegated_State(staker, operator1, withdrawals[i], withdrawals[i].strategies, withdrawals[i].shares);
}

// 5. Deposit into Strategies
uint[] memory sharesAdded = _calculateExpectedShares(strategies, numTokensRemaining);
Expand Down Expand Up @@ -359,12 +364,14 @@ contract Integration_Deposit_Delegate_Redelegate_Complete is IntegrationCheckUti
bytes32[] memory withdrawalRoots = _getWithdrawalHashes(withdrawals);
check_Undelegate_State(staker, operator1, withdrawals, withdrawalRoots, strategies, shares);

// 4. Complete withdrawal as shares
// 4. Complete withdrawal as tokens
// Fast forward to when we can complete the withdrawal
cheats.roll(block.number + delegationManager.withdrawalDelayBlocks());
uint[] memory expectedTokens = _calculateExpectedTokens(withdrawals[0].strategies, withdrawals[0].shares);
IERC20[] memory tokens = staker.completeWithdrawalAsTokens(withdrawals[0]);
check_Withdrawal_AsTokens_State(staker, operator1, withdrawals[0], strategies, shares, tokens, expectedTokens);
for (uint256 i = 0; i < withdrawals.length; ++i) {
uint[] memory expectedTokens = _calculateExpectedTokens(withdrawals[i].strategies, withdrawals[i].shares);
IERC20[] memory tokens = staker.completeWithdrawalAsTokens(withdrawals[i]);
check_Withdrawal_AsTokens_State(staker, operator1, withdrawals[i], withdrawals[i].strategies, withdrawals[i].shares, tokens, expectedTokens);
}

//5. Deposit into Strategies
staker.depositIntoEigenlayer(strategies, tokenBalances);
Expand All @@ -386,8 +393,8 @@ contract Integration_Deposit_Delegate_Redelegate_Complete is IntegrationCheckUti

// Complete withdrawals as tokens
for (uint i = 0; i < withdrawals.length; i++) {
expectedTokens = _calculateExpectedTokens(withdrawals[i].strategies, withdrawals[i].shares);
tokens = staker.completeWithdrawalAsTokens(withdrawals[i]);
uint[] memory expectedTokens = _calculateExpectedTokens(withdrawals[i].strategies, withdrawals[i].shares);
IERC20[] memory tokens = staker.completeWithdrawalAsTokens(withdrawals[i]);
check_Withdrawal_AsTokens_State(staker, operator2, withdrawals[i], strategies, shares, tokens, expectedTokens);
}
}
Expand Down Expand Up @@ -426,12 +433,14 @@ contract Integration_Deposit_Delegate_Redelegate_Complete is IntegrationCheckUti
bytes32[] memory withdrawalRoots = _getWithdrawalHashes(withdrawals);
check_Undelegate_State(staker, operator1, withdrawals, withdrawalRoots, strategies, shares);

// 4. Complete withdrawal as shares
// 4. Complete withdrawal as Tokens
// Fast forward to when we can complete the withdrawal
cheats.roll(block.number + delegationManager.withdrawalDelayBlocks());
uint[] memory expectedTokens = _calculateExpectedTokens(withdrawals[0].strategies, withdrawals[0].shares);
IERC20[] memory tokens = staker.completeWithdrawalAsTokens(withdrawals[0]);
check_Withdrawal_AsTokens_State(staker, operator1, withdrawals[0], strategies, shares, tokens, expectedTokens);
for (uint256 i = 0; i < withdrawals.length; ++i) {
uint[] memory expectedTokens = _calculateExpectedTokens(withdrawals[i].strategies, withdrawals[i].shares);
IERC20[] memory tokens = staker.completeWithdrawalAsTokens(withdrawals[i]);
check_Withdrawal_AsTokens_State(staker, operator1, withdrawals[i], withdrawals[i].strategies, withdrawals[i].shares, tokens, expectedTokens);
}

//5. Deposit into Strategies
staker.depositIntoEigenlayer(strategies, tokenBalances);
Expand All @@ -453,7 +462,6 @@ contract Integration_Deposit_Delegate_Redelegate_Complete is IntegrationCheckUti

// Complete withdrawals as shares
for (uint i = 0; i < withdrawals.length; i++) {
expectedTokens = _calculateExpectedTokens(withdrawals[i].strategies, withdrawals[i].shares);
staker.completeWithdrawalAsShares(withdrawals[i]);
check_Withdrawal_AsShares_State(staker, operator2, withdrawals[i], strategies, shares);
}
Expand Down
Loading