dapptools
dapptools copied to clipboard
Gas snapshotting
Writing this down so I don't forget. Could implement this hardhat gas snapshotting pattern pretty easily by:
-
Adding a
dapp snapshotcommand that runsdapp testand searches through the output for(gas: XXXXX), then stores the results in a.dappshotsfile (unless overriden via an env var/flag) with each test's gas usage tied to its name -
Adding a
dapp check-snapshotcommand that runsdapp 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.
ideally don't run non-concrete tests (tests prefixed with prove/invariant and standard test prefixed functions with arguments) during dapp snapshot or else things could take a while
i feel like it could make sense to add a flag for doing a "quick" run in the general case, that skips the above specified longer running tests, that we could then leverage here...wdyt
would be epic.
this is some wishlist shit but would love an env var like DAPP_TEST_MODE that could be set to 1 or 2 (0/unset would just trigger the current behavior). In mode 1 it runs all prove tests as fuzz tests for people to quickly run their whole suite and make sure there's no low hanging fruit. In mode 2 it would do what we discussed above and ignore all non-concrete tests entirely.