foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.36k stars 1.77k forks source link

Tests could warn, when vm.warp() was used to reduce/decrease the timestamp #4632

Open valle-xyz opened 1 year ago

valle-xyz commented 1 year ago

Component

Forge

Describe the feature you would like

This Situation, ok I was also stupid.

I am debugging some tests, and don't know, why they fail. In the end, it was because somewhere deep in my test setups I set vm.warp(1 hours);, and in the test I wrote I set vm.warp(1);, and this lead to a underflow error.

Proposed solution:

If this is a bad idea, just close :-)

Additional context

No response

mds1 commented 1 year ago

An alternative solution that should be simpler to implement is to have forge revert if you warp/roll to an earlier timestamp/block. I can't think of a valid use case for that, and if there is one we can add a config flag to disable this behavior

valle-xyz commented 1 year ago

Agree, that's better.