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(forge test): generate gas report of all functions in contract without the need to specify a test function for each #8713

Closed
iamkunal9 opened this issue Aug 22, 2024 · 2 comments · Fixed by #8952
Labels
A-gas-snapshots Area: gas snapshotting/reporting C-forge Command: forge Cmd-forge-test Command: forge test T-feature Type: feature

Comments

@iamkunal9
Copy link

iamkunal9 commented Aug 22, 2024

Component

Forge

Describe the feature you would like

The problem is that to obtain a gas report for an entire contract, we currently need to write test cases for each function within the contract. This is necessary to get accurate gas usage data. I'm looking for a way to generate a gas report without the need to write test cases for every function, if possible. Remix IDE offers something similar, but the results aren't very accurate.

A potential workaround is to build a script that automatically prefixes all functions in a contract with "test_" and then run forge snapshot to generate the gas report. However, if there were a way to achieve this without modifying the contract or writing specific test cases, it would be a much better solution.

Additional context

This feature would streamline the process of gas reporting, especially for large contracts where writing individual test cases for every function is cumbersome.
#4486

@iamkunal9 iamkunal9 added T-feature Type: feature T-needs-triage Type: this issue needs to be labelled labels Aug 22, 2024
@zerosnacks zerosnacks changed the title Generate gas report of a contract without writing the whole testcase. feat(forge test): generate gas report of all functions in contract without the need to specify a test function for each Aug 22, 2024
@zerosnacks zerosnacks added Cmd-forge-test Command: forge test A-gas-snapshots Area: gas snapshotting/reporting C-forge Command: forge and removed T-needs-triage Type: this issue needs to be labelled labels Aug 22, 2024
@ShantelPeters
Copy link

Please I will like to work on this

@zerosnacks
Copy link
Member

Hi @iamkunal9 thanks for your suggestion

I think your request will largely be resolved by a new gas snapshotting mechanic implemented in #8755

@grandizzy grandizzy removed this from the v1.0.0 milestone Oct 1, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Oct 1, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-gas-snapshots Area: gas snapshotting/reporting C-forge Command: forge Cmd-forge-test Command: forge test T-feature Type: feature
Projects
Archived in project
4 participants