Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(cheatcodes): assert execution revert trace of a function call within try {} catch context #8745

Closed
Brivan-26 opened this issue Aug 26, 2024 · 3 comments
Labels
A-cheatcodes Area: cheatcodes T-feature Type: feature
Milestone

Comments

@Brivan-26
Copy link

Component

Forge, Other (please describe)

Describe the feature you would like

With the introduction of try{}catch blocks in Solidity, nested calls that might revert can be handled gracefully to not enforce Transaction revert. It would be better to add an assertion in the tests suite to assert a revert of function call instead of a transaction call

For example:
Let's say function x on contract A calls function y on contract B in which it handles the revert of y gracefully using try{}catch. It would be awesome to have an assertion function that asserts the revert of function y during the execution of function x. Obviously, expectRevert can not be used since it expects transaction revert instead of function revert

Additional context

No response

@Brivan-26 Brivan-26 added T-feature Type: feature T-needs-triage Type: this issue needs to be labelled labels Aug 26, 2024
@Brivan-26 Brivan-26 changed the title Assert execution trace of a function call Assert execution revert trace of a function call within try{}catch context Aug 26, 2024
@Brivan-26 Brivan-26 changed the title Assert execution revert trace of a function call within try{}catch context feat(trace): Assert execution revert trace of a function call within try{}catch context Aug 26, 2024
@zerosnacks zerosnacks changed the title feat(trace): Assert execution revert trace of a function call within try{}catch context feat(cheatcodes): assert execution revert trace of a function call within try {} catch context Aug 26, 2024
@zerosnacks zerosnacks added A-cheatcodes Area: cheatcodes and removed T-needs-triage Type: this issue needs to be labelled labels Aug 26, 2024
@klkvr
Copy link
Member

klkvr commented Aug 26, 2024

I think this should already be possible by using vm.startStateDiffRecording and vm.stopAndReturnStateDiff by checking that reverted call to the given address is present in the returned array

Though it's not as simple as expectRevert

@zerosnacks zerosnacks added this to the v1.0.0 milestone Aug 28, 2024
@grandizzy
Copy link
Collaborator

grandizzy commented Aug 29, 2024

@Brivan-26 @zerosnacks @klkvr I think this should be solved by #5299 (comment) wdyt?

@jenpaff
Copy link
Collaborator

jenpaff commented Sep 24, 2024

solved by #5299

@jenpaff jenpaff closed this as completed Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cheatcodes Area: cheatcodes T-feature Type: feature
Projects
None yet
Development

No branches or pull requests

5 participants