Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for most random cheatcodes #877

Merged
merged 23 commits into from
Nov 20, 2024
Merged

Conversation

palinatolmach
Copy link
Collaborator

@palinatolmach palinatolmach commented Nov 7, 2024

This PR partially addresses #876.

This PR adds support for the following cheatcodes recently added to forge-std, and adds end-to-end tests for them:

    /// Returns a random `address`.
    function randomAddress() external returns (address);

    /// Returns a random `bool`.
    function randomBool() external view returns (bool);

    /// Returns a random byte array value of the given length.
    function randomBytes(uint256 len) external view returns (bytes memory);

    /// Returns a random fixed-size byte array of length 4.
    function randomBytes4() external view returns (bytes4);

    /// Returns a random fixed-size byte array of length 8.
    function randomBytes8() external view returns (bytes8);

    /// Returns a random uint256 value.
    function randomUint() external returns (uint256);

    /// Returns a random `uint256` value of given bits.
    function randomUint(uint256 bits) external view returns (uint256);

    /// Returns random uint256 value between the provided range (=min..=max).
    function randomUint(uint256 min, uint256 max) external returns (uint256);

The following cheatcodes will be added in a follow up PR; they're currently causing branching due to some signed ints specifics:

    /// Returns a random `int256` value.
    function randomInt() external view returns (int256);

    /// Returns a random `int256` value of given bits.
    function randomInt(uint256 bits) external view returns (int256);

@palinatolmach palinatolmach self-assigned this Nov 7, 2024
@palinatolmach palinatolmach changed the title Add support for random cheatcodes Add support for most random cheatcodes Nov 18, 2024
@palinatolmach palinatolmach marked this pull request as ready for review November 18, 2024 17:20
palinatolmach and others added 3 commits November 20, 2024 10:21
Co-authored-by: Andrei Văcaru <16517508+anvacaru@users.noreply.github.com>
Co-authored-by: Andrei Văcaru <16517508+anvacaru@users.noreply.github.com>
@rv-jenkins rv-jenkins merged commit 5f496c3 into master Nov 20, 2024
12 checks passed
@rv-jenkins rv-jenkins deleted the add-random-cheatcodes branch November 20, 2024 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants