Skip to content

Commit

Permalink
remove require
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKitsune committed Dec 27, 2024
1 parent c994cfd commit 1436a4f
Showing 1 changed file with 43 additions and 15 deletions.
58 changes: 43 additions & 15 deletions contracts/test/Setup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ contract Setup is Test {
///////////////////////////////////////////////////////////////////////////////

/// @notice The 4337 Entry Point on Ethereum Mainnet.
IEntryPoint internal entryPoint = IEntryPoint(address(0x0000000071727De22E5E9d8BAf0edAc6f37da032));
IEntryPoint internal entryPoint =
IEntryPoint(address(0x0000000071727De22E5E9d8BAf0edAc6f37da032));
/// @notice The PBHEntryPoint contract.
IPBHEntryPoint public pbhEntryPoint;
/// @notice The PBHSignatureAggregator contract.
Expand All @@ -37,7 +38,8 @@ contract Setup is Test {
address public pbhEntryPointImpl;
address public immutable thisAddress = address(this);
address public constant nullAddress = address(0);
address public constant MULTICALL3 = 0xcA11bde05977b3631167028862bE2a173976CA11;
address public constant MULTICALL3 =
0xcA11bde05977b3631167028862bE2a173976CA11;
///////////////////////////////////////////////////////////////////////////////
/// TEST ORCHESTRATION ///
///////////////////////////////////////////////////////////////////////////////
Expand All @@ -63,7 +65,6 @@ contract Setup is Test {

// Deposit some funds into the Entry Point from the Mock Account.
entryPoint.depositTo{value: 10 ether}(address(safe));
require(false, "here");
}

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -75,14 +76,26 @@ contract Setup is Test {
///
/// @param initialGroupAddress The initial group's identity manager.
/// @param initialEntryPoint The initial entry point.
function deployPBHEntryPoint(IWorldIDGroups initialGroupAddress, IEntryPoint initialEntryPoint) public {
function deployPBHEntryPoint(
IWorldIDGroups initialGroupAddress,
IEntryPoint initialEntryPoint
) public {
pbhEntryPointImpl = address(new PBHEntryPointImplV1());

bytes memory initCallData =
abi.encodeCall(PBHEntryPointImplV1.initialize, (initialGroupAddress, initialEntryPoint, 30, MULTICALL3));
bytes memory initCallData = abi.encodeCall(
PBHEntryPointImplV1.initialize,
(initialGroupAddress, initialEntryPoint, 30, MULTICALL3)
);
vm.expectEmit(true, true, true, true);
emit PBHEntryPointImplV1.PBHEntryPointImplInitialized(initialGroupAddress, initialEntryPoint, 30, MULTICALL3);
pbhEntryPoint = IPBHEntryPoint(address(new PBHEntryPoint(pbhEntryPointImpl, initCallData)));
emit PBHEntryPointImplV1.PBHEntryPointImplInitialized(
initialGroupAddress,
initialEntryPoint,
30,
MULTICALL3
);
pbhEntryPoint = IPBHEntryPoint(
address(new PBHEntryPoint(pbhEntryPointImpl, initCallData))
);
}

/// @notice Initializes a new PBHSignatureAggregator.
Expand All @@ -107,15 +120,20 @@ contract Setup is Test {
/// @dev It is constructed in the globals.
function makeUninitPBHEntryPoint() public {
pbhEntryPointImpl = address(new PBHEntryPointImplV1());
pbhEntryPoint = IPBHEntryPoint(address(new PBHEntryPoint(pbhEntryPointImpl, new bytes(0x0))));
pbhEntryPoint = IPBHEntryPoint(
address(new PBHEntryPoint(pbhEntryPointImpl, new bytes(0x0)))
);
}

/// @notice Asserts that making the external call using `callData` on `target` succeeds.
///
/// @param target The target at which to make the call.
/// @param callData The ABI-encoded call to a function.
function assertCallSucceedsOn(address target, bytes memory callData) public {
(bool status,) = target.call(callData);
function assertCallSucceedsOn(
address target,
bytes memory callData
) public {
(bool status, ) = target.call(callData);
assert(status);
}

Expand All @@ -124,7 +142,11 @@ contract Setup is Test {
/// @param target The target at which to make the call.
/// @param callData The ABI-encoded call to a function.
/// @param expectedReturnData The expected return data from the function.
function assertCallSucceedsOn(address target, bytes memory callData, bytes memory expectedReturnData) public {
function assertCallSucceedsOn(
address target,
bytes memory callData,
bytes memory expectedReturnData
) public {
(bool status, bytes memory returnData) = target.call(callData);
assert(status);
assertEq(expectedReturnData, returnData);
Expand All @@ -135,7 +157,7 @@ contract Setup is Test {
/// @param target The target at which to make the call.
/// @param callData The ABI-encoded call to a function.
function assertCallFailsOn(address target, bytes memory callData) public {
(bool status,) = target.call(callData);
(bool status, ) = target.call(callData);
assert(!status);
}

Expand All @@ -144,7 +166,11 @@ contract Setup is Test {
/// @param target The target at which to make the call.
/// @param callData The ABI-encoded call to a function.
/// @param expectedReturnData The expected return data from the function.
function assertCallFailsOn(address target, bytes memory callData, bytes memory expectedReturnData) public {
function assertCallFailsOn(
address target,
bytes memory callData,
bytes memory expectedReturnData
) public {
(bool status, bytes memory returnData) = target.call(callData);
assert(!status);
assertEq(expectedReturnData, returnData);
Expand All @@ -156,7 +182,9 @@ contract Setup is Test {
/// @param reason The string reason for the revert.
///
/// @return data The ABI encoding of the revert.
function encodeStringRevert(string memory reason) public pure returns (bytes memory data) {
function encodeStringRevert(
string memory reason
) public pure returns (bytes memory data) {
return abi.encodeWithSignature("Error(string)", reason);
}
}

0 comments on commit 1436a4f

Please sign in to comment.