Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stevennevins committed Sep 15, 2023
1 parent 4a19ddb commit 593e83a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 51 deletions.
1 change: 0 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[profile.default]
src = "src"
out = "out"
libs = ["lib"]

Expand Down
12 changes: 0 additions & 12 deletions script/Counter.s.sol

This file was deleted.

14 changes: 0 additions & 14 deletions src/Counter.sol

This file was deleted.

24 changes: 0 additions & 24 deletions test/Counter.t.sol

This file was deleted.

28 changes: 28 additions & 0 deletions test/Create2.t.sol
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();
}
}

0 comments on commit 593e83a

Please sign in to comment.