Skip to content

Commit

Permalink
fix nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbir committed Sep 4, 2024
1 parent 942e93f commit 493e806
Showing 1 changed file with 90 additions and 18 deletions.
108 changes: 90 additions & 18 deletions test/HoleskyIntegration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -139,24 +139,76 @@ contract HoleskyIntegration is Test {
vm.stopPrank();
}

function _generateUnsignedUserOperation(
address _sender,
bytes memory _callData
) private view returns(UserOperation memory) {
uint256 nonce = 0;
return UserOperation({
sender: _sender,
nonce: nonce,
initCode: "",
callData: _callData,
callGasLimit: 1000000,
verificationGasLimit: 1000000,
preVerificationGas: 1000000,
maxFeePerGas: 1 gwei,
maxPriorityFeePerGas: 1 gwei,
paymasterAndData: "",
signature: ""
});
function test_ProofSubmitterExecuteOnPodFromServiceViaEntryPoint() external {
uint256 deposited = 10 ether;

vm.startPrank(clientAddress);

address pod = eigenPodManager.createPod();
ProofSubmitter proofSubmitter = factory.createProofSubmitter{
value: deposited
}();
proofSubmitter.setOperator(serviceAddress);
IEigenPodMock(pod).setProofSubmitter(address(proofSubmitter));

vm.stopPrank();

bytes memory executeCallData1 = abi.encodeWithSelector(
ProofSubmitter.execute.selector,
pod,
verifyWithdrawalCredentialsCalldata
);
vm.expectCall(
address(proofSubmitter),
executeCallData1
);
vm.expectCall(
pod,
verifyWithdrawalCredentialsCalldata
);
_executeUserOperation(
address(proofSubmitter),
servicePrivateKey,
executeCallData1
);

bytes memory executeCallData2 = abi.encodeWithSelector(
ProofSubmitter.execute.selector,
pod,
startCheckpointCalldata
);
vm.expectCall(
address(proofSubmitter),
executeCallData2
);
vm.expectCall(
pod,
startCheckpointCalldata
);
_executeUserOperation(
address(proofSubmitter),
servicePrivateKey,
executeCallData2
);

bytes memory executeCallData3 = abi.encodeWithSelector(
ProofSubmitter.execute.selector,
pod,
verifyCheckpointProofsCalldata
);
vm.expectCall(
address(proofSubmitter),
executeCallData3
);
vm.expectCall(
pod,
verifyCheckpointProofsCalldata
);
_executeUserOperation(
address(proofSubmitter),
servicePrivateKey,
executeCallData3
);
}

function test_ProofSubmitterExecuteOnRewardsCoordinatorFromServiceViaEntryPoint()
Expand Down Expand Up @@ -194,6 +246,26 @@ contract HoleskyIntegration is Test {
);
}

function _generateUnsignedUserOperation(
address _sender,
bytes memory _callData
) private view returns(UserOperation memory) {
uint256 nonce = entryPoint.getNonce(_sender, 0);
return UserOperation({
sender: _sender,
nonce: nonce,
initCode: "",
callData: _callData,
callGasLimit: 1000000,
verificationGasLimit: 1000000,
preVerificationGas: 1000000,
maxFeePerGas: 1 gwei,
maxPriorityFeePerGas: 1 gwei,
paymasterAndData: "",
signature: ""
});
}

function _executeUserOperation(
address _smartAccountAddress,
uint256 _signerPrivateKey,
Expand Down

0 comments on commit 493e806

Please sign in to comment.