Skip to content

Commit

Permalink
feat: add assumeUnusedAddress (#639)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xenide authored Jan 7, 2025
1 parent b5a8691 commit 726a6ee
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/StdCheats.sol
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,18 @@ abstract contract StdCheatsSafe {
);
}

function assumeUnusedAddress(address addr) internal view virtual {
uint256 size;
assembly {
size := extcodesize(addr)
}
vm.assume(size == 0);

assumeNotPrecompile(addr);
assumeNotZeroAddress(addr);
assumeNotForgeAddress(addr);
}

function readEIP1559ScriptArtifact(string memory path)
internal
view
Expand Down

0 comments on commit 726a6ee

Please sign in to comment.