From a257f46bb418a221bee221f9ce120c58c8059c76 Mon Sep 17 00:00:00 2001 From: sidu28 <60323455+Sidu28@users.noreply.github.com> Date: Mon, 9 Oct 2023 10:54:27 -0700 Subject: [PATCH] almost all tests working --- src/test/unit/EigenPodUnit.t.sol | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/unit/EigenPodUnit.t.sol b/src/test/unit/EigenPodUnit.t.sol index 784b2ff4b..74139e1a4 100644 --- a/src/test/unit/EigenPodUnit.t.sol +++ b/src/test/unit/EigenPodUnit.t.sol @@ -248,7 +248,8 @@ contract EigenPodUnitTests is EigenPodTests { * will simply send the entire ETH balance (32 ETH) to the owner. The owner activates restaking, * creates a validator and verifies the withdrawal credentials, receiving 32 ETH in shares. * They can exit the validator, the pod gets the 32ETH and they can call withdrawNonBeaconChainETHBalanceWei - * And simply withdraw the 32ETH because nonBeaconChainETHBalanceWei is 32ETH. + * And simply withdraw the 32ETH because nonBeaconChainETHBalanceWei is 32ETH. This was an issue because + * nonBeaconChainETHBalanceWei was never zeroed out in _processWithdrawalBeforeRestaking */ function testValidatorBalanceCannotBeRemovedFromPodViaNonBeaconChainETHBalanceWei() external { cheats.startPrank(podOwner); @@ -261,11 +262,16 @@ contract EigenPodUnitTests is EigenPodTests { uint256 amount = 32 ether; cheats.deal(address(this), amount); + // simulate a withdrawal processed on the beacon chain, pod balance goes to 32 ETH Address.sendValue(payable(address(newPod)), amount); require(newPod.nonBeaconChainETHBalanceWei() == amount, "nonBeaconChainETHBalanceWei should be 32 ETH"); + //simulate that hasRestaked is set to false, so that we can test withdrawBeforeRestaking for pods deployed before M2 activation + cheats.store(address(newPod), bytes32(uint256(52)), bytes32(uint256(1))); //this is an M1 pod so hasRestaked should be false require(newPod.hasRestaked() == false, "Pod should be restaked"); + cheats.startPrank(podOwner); newPod.activateRestaking(); + cheats.stopPrank(); require(newPod.nonBeaconChainETHBalanceWei() == 0, "nonBeaconChainETHBalanceWei should be 32 ETH"); }