@@ -2126,3 +2126,140 @@ contract Relayer is Test {
21262126 BeaconChainProofs.verifyWithdrawal (beaconStateRoot, withdrawalFields, proofs);
21272127 }
21282128}
2129+
2130+
2131+ //TODO: Integration Tests from old EPM unit tests:
2132+ // queues a withdrawal of "beacon chain ETH shares" from this address to itself
2133+ // fuzzed input amountGwei is sized-down, since it must be in GWEI and gets sized-up to be WEI
2134+ // TODO: reimplement similar test
2135+ // function testQueueWithdrawalBeaconChainETHToSelf(uint128 amountGwei)
2136+ // public returns (IEigenPodManager.BeaconChainQueuedWithdrawal memory, bytes32 /*withdrawalRoot*/)
2137+ // {
2138+ // // scale fuzzed amount up to be a whole amount of GWEI
2139+ // uint256 amount = uint256(amountGwei) * 1e9;
2140+ // address staker = address(this);
2141+ // address withdrawer = staker;
2142+
2143+ // testRestakeBeaconChainETHSuccessfully(staker, amount);
2144+
2145+ // (IEigenPodManager.BeaconChainQueuedWithdrawal memory queuedWithdrawal, bytes32 withdrawalRoot) =
2146+ // _createQueuedWithdrawal(staker, amount, withdrawer);
2147+
2148+ // return (queuedWithdrawal, withdrawalRoot);
2149+ // }
2150+ // TODO: reimplement similar test
2151+ // function testQueueWithdrawalBeaconChainETHToDifferentAddress(address withdrawer, uint128 amountGwei)
2152+ // public
2153+ // filterFuzzedAddressInputs(withdrawer)
2154+ // returns (IEigenPodManager.BeaconChainQueuedWithdrawal memory, bytes32 /*withdrawalRoot*/)
2155+ // {
2156+ // // scale fuzzed amount up to be a whole amount of GWEI
2157+ // uint256 amount = uint256(amountGwei) * 1e9;
2158+ // address staker = address(this);
2159+
2160+ // testRestakeBeaconChainETHSuccessfully(staker, amount);
2161+
2162+ // (IEigenPodManager.BeaconChainQueuedWithdrawal memory queuedWithdrawal, bytes32 withdrawalRoot) =
2163+ // _createQueuedWithdrawal(staker, amount, withdrawer);
2164+
2165+ // return (queuedWithdrawal, withdrawalRoot);
2166+ // }
2167+ // TODO: reimplement similar test
2168+
2169+ // function testQueueWithdrawalBeaconChainETHFailsNonWholeAmountGwei(uint256 nonWholeAmount) external {
2170+ // // this also filters out the zero case, which will revert separately
2171+ // cheats.assume(nonWholeAmount % GWEI_TO_WEI != 0);
2172+ // cheats.expectRevert(bytes("EigenPodManager._queueWithdrawal: cannot queue a withdrawal of Beacon Chain ETH for an non-whole amount of gwei"));
2173+ // eigenPodManager.queueWithdrawal(nonWholeAmount, address(this));
2174+ // }
2175+
2176+ // function testQueueWithdrawalBeaconChainETHFailsZeroAmount() external {
2177+ // cheats.expectRevert(bytes("EigenPodManager._queueWithdrawal: amount must be greater than zero"));
2178+ // eigenPodManager.queueWithdrawal(0, address(this));
2179+ // }
2180+
2181+ // TODO: reimplement similar test
2182+ // function testCompleteQueuedWithdrawal() external {
2183+ // address staker = address(this);
2184+ // uint256 withdrawalAmount = 1e18;
2185+
2186+ // // withdrawalAmount is converted to GWEI here
2187+ // (IEigenPodManager.BeaconChainQueuedWithdrawal memory queuedWithdrawal, bytes32 withdrawalRoot) =
2188+ // testQueueWithdrawalBeaconChainETHToSelf(uint128(withdrawalAmount / 1e9));
2189+
2190+ // IEigenPod eigenPod = eigenPodManager.getPod(staker);
2191+ // uint256 eigenPodBalanceBefore = address(eigenPod).balance;
2192+
2193+ // uint256 middlewareTimesIndex = 0;
2194+
2195+ // // actually complete the withdrawal
2196+ // cheats.startPrank(staker);
2197+ // cheats.expectEmit(true, true, true, true, address(eigenPodManager));
2198+ // emit BeaconChainETHWithdrawalCompleted(
2199+ // queuedWithdrawal.podOwner,
2200+ // queuedWithdrawal.shares,
2201+ // queuedWithdrawal.nonce,
2202+ // queuedWithdrawal.delegatedAddress,
2203+ // queuedWithdrawal.withdrawer,
2204+ // withdrawalRoot
2205+ // );
2206+ // eigenPodManager.completeQueuedWithdrawal(queuedWithdrawal, middlewareTimesIndex);
2207+ // cheats.stopPrank();
2208+
2209+ // // TODO: make EigenPodMock do something so we can verify that it gets called appropriately?
2210+ // uint256 eigenPodBalanceAfter = address(eigenPod).balance;
2211+
2212+ // // verify that the withdrawal root does bit exist after queuing
2213+ // require(!eigenPodManager.withdrawalRootPending(withdrawalRoot), "withdrawalRootPendingBefore is true!");
2214+ // }
2215+
2216+ // TODO: reimplement similar test
2217+ // // creates a queued withdrawal of "beacon chain ETH shares", from `staker`, of `amountWei`, "to" the `withdrawer`
2218+ // function _createQueuedWithdrawal(address staker, uint256 amountWei, address withdrawer)
2219+ // internal
2220+ // returns (IEigenPodManager.BeaconChainQueuedWithdrawal memory queuedWithdrawal, bytes32 withdrawalRoot)
2221+ // {
2222+ // // create the struct, for reference / to return
2223+ // queuedWithdrawal = IEigenPodManager.BeaconChainQueuedWithdrawal({
2224+ // shares: amountWei,
2225+ // podOwner: staker,
2226+ // nonce: eigenPodManager.cumulativeWithdrawalsQueued(staker),
2227+ // startBlock: uint32(block.number),
2228+ // delegatedTo: delegationManagerMock.delegatedTo(staker),
2229+ // withdrawer: withdrawer
2230+ // });
2231+
2232+ // // verify that the withdrawal root does not exist before queuing
2233+ // require(!eigenPodManager.withdrawalRootPending(withdrawalRoot), "withdrawalRootPendingBefore is true!");
2234+
2235+ // // get staker nonce and shares before queuing
2236+ // uint256 nonceBefore = eigenPodManager.cumulativeWithdrawalsQueued(staker);
2237+ // int256 sharesBefore = eigenPodManager.podOwnerShares(staker);
2238+
2239+ // // actually create the queued withdrawal, and check for event emission
2240+ // cheats.startPrank(staker);
2241+
2242+ // cheats.expectEmit(true, true, true, true, address(eigenPodManager));
2243+ // emit BeaconChainETHWithdrawalQueued(
2244+ // queuedWithdrawal.podOwner,
2245+ // queuedWithdrawal.shares,
2246+ // queuedWithdrawal.nonce,
2247+ // queuedWithdrawal.delegatedAddress,
2248+ // queuedWithdrawal.withdrawer,
2249+ // eigenPodManager.calculateWithdrawalRoot(queuedWithdrawal)
2250+ // );
2251+ // withdrawalRoot = eigenPodManager.queueWithdrawal(amountWei, withdrawer);
2252+ // cheats.stopPrank();
2253+
2254+ // // verify that the withdrawal root does exist after queuing
2255+ // require(eigenPodManager.withdrawalRootPending(withdrawalRoot), "withdrawalRootPendingBefore is false!");
2256+
2257+ // // verify that staker nonce incremented correctly and shares decremented correctly
2258+ // uint256 nonceAfter = eigenPodManager.cumulativeWithdrawalsQueued(staker);
2259+ // int256 sharesAfter = eigenPodManager.podOwnerShares(staker);
2260+ // require(nonceAfter == nonceBefore + 1, "nonce did not increment correctly on queuing withdrawal");
2261+ // require(sharesAfter + amountWei == sharesBefore, "shares did not decrement correctly on queuing withdrawal");
2262+
2263+ // return (queuedWithdrawal, withdrawalRoot);
2264+ // }
2265+
0 commit comments