Skip to content

feat(forge): add gas snapshotting #204

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

Merged
merged 17 commits into from
Dec 11, 2021
Merged

Conversation

mattsse
Copy link
Member

@mattsse mattsse commented Dec 10, 2021

Changes

  • Move several commands from forge.rs to their dedicated sub modules
  • Add snapshot command, that essentially "inherits" from test
  • add snapshot --diff <snapshot> to print the diff from the current snapshot and an existing snapshot file
  • add snapshot --check <snapshot> to check the current snapshot and an existing snapshot file, similar to cargo fmt --check

Supports all forge test arguments

Ref #137

help = "Compare against a snapshot and display changes from the snapshot. Takes an optional snapshot file, [default: .gas-snapshot]",
long
)]
diff: Option<Option<PathBuf>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this double option needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah so this allows us to pass --diff as flag, in which case we take the .gas-snapshot file for comparison or

--diff to compare against a specific snapshot file


fn run(self) -> eyre::Result<()> {
dbg!(self);
todo!()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the expected behavior for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intended for check-snapshot as mentioned here dapphub/dapptools#761

Adding a dapp check-snapshot command that runs dapp snapshot (but outputs to a temp file instead of .dappshots) and compares it with .dappshots. If they don't match the command exits with an error.

help = "Compare against a snapshot and display changes from the snapshot. Takes an optional snapshot file, [default: .gas-snapshot]",
long
)]
diff: Option<Option<PathBuf>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this double option needed?

Copy link
Member

@gakonst gakonst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - we can track the prettier table printing separately

@gakonst gakonst merged commit d90e897 into foundry-rs:master Dec 11, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants