Comments (7)
Just want to clarify in case anyone picks this up, since the format and example seem to differ a bit. I'd personally suggest:
require(condition, "ContractName (functionName): Error message here.");
In other words, no underscores in the require statements. Alternatively, we could do functionSig (e.g. deal(address,uint256)
) instead of functionName (e.g. deal
) to help disambiguate overloaded functions.
from forge-std.
We can use the same PR to standardize the error messages to be easy to figure out what reverted.
Format:
ContractName_(functionName)__Error_message
Example:
Traces:
[144] ContractTest::setUp()
└─ ← ()
[123470] ContractTest::testExample()
├─ [0] VM::record()
│ └─ ← ()
├─ [236] ContractTest::a42c4a23(000000000000000000000000b4c79dab8f259c7aee6e5b2aa729821864227e84) [staticcall]
│ └─ ← ()
├─ [0] VM::accesses(ContractTest: [0xb4c79dab8f259c7aee6e5b2aa729821864227e84])
│ └─ ← [], []
└─ ← "StdStorage (find) No storage use detected for target"
Test result: FAILED. 0 passed; 1 failed; finished in 1.09ms
Failed tests:
[FAIL. Reason: StdStorage (find) No storage use detected for target] testExample() (gas: 123470)
from forge-std.
Ok, will do that.
from forge-std.
Just reread this. There are definitely more causes of reasons this can fail aside from those two, so maybe just Deployment failed
as the error message
from forge-std.
@ZeroEkkusu just have to check for zero
address reverts, right?
Should I add tests for failures as well?
from forge-std.
@dsam82 Yes. Will you also standardize the other error messages?
I'd suggest this format based on Matt's suggestions:
require(condition, "ContractName functionName(type,type): Error message here.");
Should I add tests for failures as well?
Yes, please. But @dsam82 this part is not too important; you don't have to do it unless you already had an idea for a test.
from forge-std.
I had an idea of creating a simple reverting contract and then using deployCode
to check for zero address reverts.
Currently encountering an error: expectRevert
is not working even though revert is being thrown.
Will create a draft PR soon.
from forge-std.
Related Issues (20)
- JSON Parsing with Default Fallbacks HOT 3
- ENV var incorrectly takes precedence over CLI flag HOT 1
- [FAIL. Reason: revert: stdStorage find(StdStorage): No storage use detected for target.] HOT 5
- Native String Cheatcodes Not Present HOT 2
- contract creation code storage out of gas HOT 1
- `DSTest` removal in v1.8.0 seems to break the `forge` contract sizer filter HOT 1
- assertEq "Invalid data" HOT 2
- Add prompt cheatcode
- Change `vm` visibility to internal in `StdAssertions` and `StdUtils` HOT 2
- Package.json version is not updated. HOT 4
- Feature request: block gas limits for most popular chains HOT 2
- 1.7.1 -> 1.8.1 breaking change: why is DSTest no longer inherited by Test? HOT 1
- Add Vm.prevrandao as uint256 overloaded function
- Add envExists cheatcode function
- Add isContext cheatcode function HOT 1
- add new blobhash cheatcodes HOT 2
- Can't seem to read `CallerMode` from `vm.readCallers()` HOT 4
- Add new random cheatcodes HOT 3
- [FAIL. Reason: revert: stdStorage find(StdStorage): Failed to write value.] HOT 2
- Feature Request: Improved delegatecall detection in forge-std
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forge-std.