Skip to content

Uniswap/snapshot-gas-cost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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())
    })
})

About

Tiny utility package for snapshotting gas costs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published