-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring over custom errors definitions for tests
- Loading branch information
Showing
2 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity ^0.8.23; | ||
|
||
import "@account-abstraction/contracts/core/BasePaymaster.sol"; | ||
|
||
/** | ||
* test postOp revert with custom error | ||
*/ | ||
error CustomError(string customReason); | ||
|
||
contract TestPaymasterRevertCustomError is BasePaymaster { | ||
bytes32 private constant INNER_OUT_OF_GAS = hex"deaddead"; | ||
|
||
enum RevertType { | ||
customError, | ||
entryPointError | ||
} | ||
|
||
RevertType private revertType; | ||
|
||
// solhint-disable no-empty-blocks | ||
constructor(IEntryPoint _entryPoint) BasePaymaster(_entryPoint) | ||
{} | ||
|
||
function _validatePaymasterUserOp(PackedUserOperation calldata userOp, bytes32, uint256) | ||
internal virtual override view | ||
returns (bytes memory context, uint256 validationData) { | ||
validationData = 0; | ||
context = abi.encodePacked(userOp.sender); | ||
} | ||
|
||
function setRevertType(RevertType _revertType) external { | ||
revertType = _revertType; | ||
} | ||
|
||
function _postOp(PostOpMode, bytes calldata, uint256, uint256) internal view override { | ||
if (revertType == RevertType.customError){ | ||
revert CustomError("this is a long revert reason string we are looking for"); | ||
} | ||
else if (revertType == RevertType.entryPointError){ | ||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
mstore(0, INNER_OUT_OF_GAS) | ||
revert(0, 32) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters