Skip to content

feat(cheatcodes): show detailed reverts regardless of verbosity level defined #928

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
onbjerg opened this issue Mar 14, 2022 · 1 comment
Labels
A-cheatcodes Area: cheatcodes C-forge Command: forge Cmd-forge-test Command: forge test P-high Priority: high T-feature Type: feature

Comments

@onbjerg
Copy link
Collaborator

onbjerg commented Mar 14, 2022

Currently when a cheatcode reverts a single-line reason is provided. This works great for some cheatcodes, but for others, this might prove to be pretty cluttered if we want to provide detailed explanations of why the cheatcode reverted.

Having a mechanism by which we can provide more detailed cheatcode reverts will allow us to:

  • Explain why cheatcodes like expectEmit reverted
  • Link to relevant docs, guiding users on common mistakes and solutions

These are technically possible today, but it would result in a very long single line revert message which would be hard to read.

I propose that we always display logs for failed tests. Currently they are hidden behind some level of verbosity, but we only ever print console.log and DSTest-style logs. The truth is that these are usually only emitted when you are debugging or an assertion fails. In the first case, they are probably temporarily added to debug an issue, in which case, the test is probably failing. In the second case, the test is failing, and you probably want them to show up.

If we do this, then cheatcodes could inject fake logs for longer-form revert explanations.

@onbjerg onbjerg added T-question Type: question T-feature Type: feature Cmd-forge-test Command: forge test C-forge Command: forge A-cheatcodes Area: cheatcodes labels Mar 14, 2022
@onbjerg
Copy link
Collaborator Author

onbjerg commented Mar 14, 2022

Ref #592 and #908

@onbjerg onbjerg moved this to Todo in Foundry Apr 17, 2022
@onbjerg onbjerg added this to Foundry Apr 17, 2022
@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
@zerosnacks zerosnacks added T-to-discuss Type: requires discussion and removed T-question Type: question labels Aug 1, 2024
@zerosnacks zerosnacks changed the title Assertion message improvements feat(forge): add hints to error message on failing assertions Aug 1, 2024
@zerosnacks zerosnacks changed the title feat(forge): add hints to error message on failing assertions feat(cheatcodes): add hints to error message on failing assertions Aug 1, 2024
@zerosnacks zerosnacks changed the title feat(cheatcodes): add hints to error message on failing assertions feat(cheatcodes): show detailed reverts regardless of verbosity level defined Sep 11, 2024
@zerosnacks zerosnacks added P-high Priority: high and removed T-to-discuss Type: requires discussion labels Sep 11, 2024
@grandizzy grandizzy removed this from the v1.0.0 milestone Nov 5, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-cheatcodes Area: cheatcodes C-forge Command: forge Cmd-forge-test Command: forge test P-high Priority: high T-feature Type: feature
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants