-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(forge): Optionally use create2 factory in tests and non-broadcast…
…ing scripts (#6656) * fix(forge): Optionally use create2 factory in tests * Update crates/cheatcodes/src/inspector.rs * Update crates/cheatcodes/src/inspector.rs Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de> --------- Co-authored-by: Enrique <hi@enriqueortiz.dev> Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
- Loading branch information
1 parent
9b73e06
commit 9fe9a3f
Showing
9 changed files
with
129 additions
and
18 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
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
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
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
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
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
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
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
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,37 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import "ds-test/test.sol"; | ||
import "../cheats/Vm.sol"; | ||
|
||
contract Counter { | ||
uint256 public number; | ||
|
||
function setNumber(uint256 newNumber) public { | ||
number = newNumber; | ||
} | ||
|
||
function increment() public { | ||
number++; | ||
} | ||
} | ||
|
||
contract Issue5529Test is DSTest { | ||
Vm constant vm = Vm(HEVM_ADDRESS); | ||
|
||
Counter public counter; | ||
address public constant default_create2_factory = 0x4e59b44847b379578588920cA78FbF26c0B4956C; | ||
|
||
function testCreate2FactoryUsedInTests() public { | ||
address a = vm.computeCreate2Address(0, keccak256(type(Counter).creationCode), address(default_create2_factory)); | ||
address b = address(new Counter{salt: 0}()); | ||
require(a == b, "create2 address mismatch"); | ||
} | ||
|
||
function testCreate2FactoryUsedWhenPranking() public { | ||
vm.startPrank(address(1234)); | ||
address a = vm.computeCreate2Address(0, keccak256(type(Counter).creationCode), address(default_create2_factory)); | ||
address b = address(new Counter{salt: 0}()); | ||
require(a == b, "create2 address mismatch"); | ||
} | ||
} |