GnosisSafe.ERC20.spec.ts 1.06 KB
Newer Older
vicotor's avatar
vicotor committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
import { expect } from "chai";
import { waffle, ethers } from "hardhat";
import "@nomiclabs/hardhat-ethers";
import { buildSafeTransaction } from "../src/utils/execution";
import { BigNumber } from "ethers";
import { benchmark, Contracts } from "./utils/setup"

const [, , , , user5] = waffle.provider.getWallets();

benchmark("ERC20", [{
    name: "transfer",
    prepare: async (contracts: Contracts, target: string, nonce: number) => {
        const token = contracts.additions.token
        await token.transfer(target, 1000)
        const data = token.interface.encodeFunctionData("transfer", [user5.address, 500])
        return buildSafeTransaction({ to: token.address, data, safeTxGas: 1000000, nonce })
    },
    after: async (contracts: Contracts) => {
        expect(
            await contracts.additions.token.balanceOf(user5.address)
        ).to.be.deep.eq(BigNumber.from(500))
    },
    fixture: async () => {
        const tokenFactory = await ethers.getContractFactory("ERC20Token")
        return {
            token: await tokenFactory.deploy()
        }
    }
}])