Skip to content

feat(invariant): fuzz timestamp and block number for each consecutive transaction #12332

@rappie

Description

@rappie

Component

Forge

Describe the feature you would like

Foundry should increase the timestamp and blocknumber of each consecutive transation. This is useful for testing time-dependent invariants. Currently the only way to do this is to manually add a handler to perform warping and rolling.

For anyone facing the issue currently, here's the one i'm using:

    function warpAndRoll(uint256 timeAmount, uint256 blockAmount) public {
        timeAmount = timeAmount % 60480; // echidna default
        blockAmount = blockAmount % 60480; // echidna default
        vm.warp(block.timestamp + timeAmount);
        vm.roll(block.number + blockAmount);
    }

The amount by which the timestamp or block number is increased should be configurable. Link to Echidna's defaults: https://github.com/crytic/echidna/blob/master/tests/solidity/basic/default.yaml#L67-L70

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions