Giter Site home page Giter Site logo

Comments (7)

mds1 avatar mds1 commented on August 15, 2024 3

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.

ZeroEkkusu avatar ZeroEkkusu commented on August 15, 2024 2

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.

lonerapier avatar lonerapier commented on August 15, 2024 1

Ok, will do that.

from forge-std.

mds1 avatar mds1 commented on August 15, 2024

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.

lonerapier avatar lonerapier commented on August 15, 2024

@ZeroEkkusu just have to check for zero address reverts, right?

Should I add tests for failures as well?

from forge-std.

ZeroEkkusu avatar ZeroEkkusu commented on August 15, 2024

@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.

lonerapier avatar lonerapier commented on August 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.