From b6e991ce5026c201a42e86e5782fb3e1de5edca1 Mon Sep 17 00:00:00 2001 From: danoctavian Date: Sat, 28 Sep 2024 02:20:55 +0300 Subject: [PATCH] make checkpoint function --- .../M3/WithdrawalsWithRewards-Scenario.t.sol | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/test/integration/M3/WithdrawalsWithRewards-Scenario.t.sol b/test/integration/M3/WithdrawalsWithRewards-Scenario.t.sol index 2761c9cc4..01a8d045e 100644 --- a/test/integration/M3/WithdrawalsWithRewards-Scenario.t.sol +++ b/test/integration/M3/WithdrawalsWithRewards-Scenario.t.sol @@ -119,7 +119,28 @@ contract M3WithdrawalsWithRewardsTest is Base { } runSystemStateInvariants(state.totalAssetsBefore, state.totalSupplyBefore, state.stakingNodeBalancesBefore); - + + } + + function startAndVerifyCheckpoint(uint256 nodeId, TestState memory state) private { + // start checkpoint + { + vm.startPrank(actors.ops.STAKING_NODES_OPERATOR); + stakingNodesManager.nodes(nodeId).startCheckpoint(true); + vm.stopPrank(); + } + + runSystemStateInvariants(state.totalAssetsBefore, state.totalSupplyBefore, state.stakingNodeBalancesBefore); + + // verify checkpoints + { + IStakingNode _node = stakingNodesManager.nodes(nodeId); + CheckpointProofs memory _cpProofs = beaconChain.getCheckpointProofs(validatorIndices, _node.eigenPod().currentCheckpointTimestamp()); + IPod(address(_node.eigenPod())).verifyCheckpointProofs({ + balanceContainerProof: _cpProofs.balanceContainerProof, + proofs: _cpProofs.balanceProofs + }); + } } function test_userWithdrawalWithRewards_Scenario_1() public { @@ -153,24 +174,7 @@ contract M3WithdrawalsWithRewardsTest is Base { runSystemStateInvariants(state.totalAssetsBefore, state.totalSupplyBefore, state.stakingNodeBalancesBefore); - // start checkpoint - { - vm.startPrank(actors.ops.STAKING_NODES_OPERATOR); - stakingNodesManager.nodes(nodeId).startCheckpoint(true); - vm.stopPrank(); - } - - runSystemStateInvariants(state.totalAssetsBefore, state.totalSupplyBefore, state.stakingNodeBalancesBefore); - - // verify checkpoints - { - IStakingNode _node = stakingNodesManager.nodes(nodeId); - CheckpointProofs memory _cpProofs = beaconChain.getCheckpointProofs(validatorIndices, _node.eigenPod().currentCheckpointTimestamp()); - IPod(address(_node.eigenPod())).verifyCheckpointProofs({ - balanceContainerProof: _cpProofs.balanceContainerProof, - proofs: _cpProofs.balanceProofs - }); - } + startAndVerifyCheckpoint(nodeId, state); // Rewards accumulated are accounted after verifying the checkpoint state.totalAssetsBefore += accumulatedRewards;