foundry icon indicating copy to clipboard operation
foundry copied to clipboard

feat(forge): error hints

Open onbjerg opened this issue 3 years ago • 3 comments

Motivation

Some cheatcodes lack context when they fail, but our current setup does not allow us to add very much context without the output of forge test becoming super cluttered

Solution

Allow reverts from our backend and our inspectors to include optional hints

Effectively closes https://github.com/foundry-rs/foundry/issues/928 as some of the more annoying cheatcode reverts are documented in other issues

onbjerg avatar Sep 08 '22 16:09 onbjerg

@gakonst adding an example rn, but for example u could use it for expectEmit - its a long standing issue that the error msg sucks a lot here since it doesn't tell u what part of the log didn't match, so u could add hints that explain what parts match and what parts dont

onbjerg avatar Sep 08 '22 16:09 onbjerg

Not the best example (expectEmit will take more work) but instead of writing the really big number inside of the short test result it could be a hint:

image

Similarly, sometimes the forking backend might fail for whatever reason - it might be that the account is not accessible on your node, so a hint could be added that it's too far back if we think it is and suggest an archive node or moving the block you're forking from

onbjerg avatar Sep 08 '22 16:09 onbjerg

OK! This makes sense. Supportive.

gakonst avatar Sep 20 '22 00:09 gakonst

Closing as stale.

gakonst avatar Jan 17 '23 19:01 gakonst