Repository navigation
fix: make solidity --snapshot-check read-only - #8391
Conversation
🦋 Changeset detectedLatest commit: a52bd4c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This PR updates Hardhat’s Solidity gas snapshot checking so hardhat test solidity --snapshot-check becomes strictly read-only: it no longer bootstraps, rewrites, or deletes snapshot baseline files on disk, and instead only reports differences (failing only on changed tracked values) with improved “read-only” wording.
Changes:
- Make
--snapshot-checkstop writing/updating.gas-snapshotandsnapshots/*.json(including avoiding deletions on scoped runs). - Replace “written” semantics with an explicit
noBaselinesignal and update log output to match the new behavior. - Update and extend tests, including a regression test for the “scoped run deletes group files” scenario from #8358.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/hardhat/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.ts | Removes baseline writes during snapshot-check; introduces noBaseline and updates logging for added/removed output wording. |
| packages/hardhat/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.ts | Removes baseline writes/deletions during snapshot-check; introduces noBaseline and adjusts log messaging for read-only behavior. |
| packages/hardhat/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.ts | Updates snapshot-check result logging conditions to use noBaseline instead of “written”. |
| packages/hardhat/test/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.ts | Updates assertions to validate read-only behavior and adds regression coverage for scoped runs not deleting snapshot group files. |
| .changeset/quiet-melons-wave.md | Adds a patch changeset documenting the read-only --snapshot-check behavior change. |
…ed/removed on filtered runs
|
@kanej I've addressed all of the requested changes. Can you take another look? |
--snapshot-checkno longer writes or deletes snapshot files. It exits with an error only when a tracked gas value differs; snapshots added or missing relative to the baseline are reported for information only; a missing baseline is reported with a hint to run--snapshot. Output reworded to read-only language. Tests updated, with a regression test covering the scoped-run-deletes-group-files scenario from the issue.Closes #8358.
Docs updated NomicFoundation/hardhat-website#278.
Screenshots
Added/removed snapshots
No baseline (fn snapshots)
No baseline (both)
Combined (failed + added + no baseline)