-
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.
- Loading branch information
1 parent
4a19ddb
commit 593e83a
Showing
5 changed files
with
28 additions
and
51 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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
[profile.default] | ||
src = "src" | ||
out = "out" | ||
libs = ["lib"] | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import {Test} from "forge-std/Test.sol"; | ||
|
||
contract Emitter { | ||
event Ping(); | ||
|
||
function ping() external { | ||
emit Ping(); | ||
} | ||
} | ||
|
||
contract Create2Test is Test { | ||
function test_Create2() public { | ||
bytes32 salt = bytes32(0); | ||
bytes memory creationCode = type(Emitter).creationCode; | ||
bytes memory initCode = bytes.concat(creationCode, abi.encode()); | ||
(bool success,) = CREATE2_FACTORY.call(bytes.concat(salt, initCode)); | ||
assertTrue(success); | ||
address predictedTo = computeCreate2Address(salt, hashInitCode(creationCode)); | ||
|
||
(success,) = CREATE2_FACTORY.call(bytes.concat(salt, initCode)); | ||
assertFalse(success); | ||
|
||
Emitter(predictedTo).ping(); | ||
} | ||
} |