Skip to content

Commit 726a6ee

Browse files
authored
feat: add assumeUnusedAddress (#639)
Sometimes during fuzzing we want to test with a wide range of addresses, but these address need to be empty and not already have contracts deployed. This function would come in handy for that.
1 parent b5a8691 commit 726a6ee

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/StdCheats.sol

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,18 @@ abstract contract StdCheatsSafe {
349349
);
350350
}
351351

352+
function assumeUnusedAddress(address addr) internal view virtual {
353+
uint256 size;
354+
assembly {
355+
size := extcodesize(addr)
356+
}
357+
vm.assume(size == 0);
358+
359+
assumeNotPrecompile(addr);
360+
assumeNotZeroAddress(addr);
361+
assumeNotForgeAddress(addr);
362+
}
363+
352364
function readEIP1559ScriptArtifact(string memory path)
353365
internal
354366
view

0 commit comments

Comments
 (0)