@uniswap/snapshot-gas-cost
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@uniswap/snapshot-gas-cost

Tiny utility function for snapshotting gas costs in unit tests.

Objective

This function is useful for smart contract testing against hardhat networks. Use it to produce snapshot diffs that you commit to your repository.

Usage

import snapshotGasCost from '@uniswap/snapshot-gas-cost'
import {Contract} from "@ethersproject/contracts";

describe('gas tests', () => {
    let myContract: Contract
    beforeEach('initialize contract', () => {
        /// initialize myContract
    })
    
    it('gas snapshot for a mutable function', async () => {
        await snapshotGasCost(myContract.someMutableFunction())
    })
    
    it('gas snapshot for a view function', async () => {
        await snapshotGasCost(myContract.estimateGas.someViewFunction())
    })
})

Readme

Keywords

none

Package Sidebar

Install

npm i @uniswap/snapshot-gas-cost

Weekly Downloads

142

Version

1.0.0

License

GPL-2.0-or-later

Unpacked Size

23.3 kB

Total Files

8

Last publish

Collaborators