Skip to content

Commit

Permalink
make checkpoint function
Browse files Browse the repository at this point in the history
  • Loading branch information
danoctavian committed Sep 27, 2024
1 parent 91880e7 commit b6e991c
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions test/integration/M3/WithdrawalsWithRewards-Scenario.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b6e991c

Please sign in to comment.