Skip to content

Support gas snapshots for Solidity tests #7769

@schaable

Description

@schaable

Describe the issue

Add support for gas snapshots in Solidity tests. This includes:

  1. Test function gas snapshots: Store gas usage for each test function in a .gas-snapshot file (unit tests: single value, fuzz tests: average & median, invariant tests: skipped)

  2. Snapshot cheatcodes: Store gas usage or arbitrary values at specific points in tests using cheatcodes (startSnapshotGas, stopSnapshotGas, snapshotGasLastCall, snapshotValue). Values are stored in snapshots/{group}.json files. The cheatcodes themselves are already implemented in EDR.

Both features are controlled by new CLI flags:

  • --snapshot: Generate/update snapshot files
  • --snapshot-check: Validate current values against stored snapshots, exit with non-zero code on mismatch

See the design doc for details.

Sub-issues

Metadata

Metadata

Assignees

Labels

_priority:P1High prioritytype:KREnd-to-end implementation of a KR

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions