diff --git a/foundry.toml b/foundry.toml index e6810b2..069113c 100644 --- a/foundry.toml +++ b/foundry.toml @@ -2,5 +2,6 @@ src = 'src' out = 'out' libs = ['lib'] +gas_reports = ["ERC721ACHMock"] # See more config options https://github.com/foundry-rs/foundry/tree/master/config \ No newline at end of file diff --git a/test/ERC721ACH.t.sol b/test/ERC721ACH.t.sol index 8348e25..f8a3126 100644 --- a/test/ERC721ACH.t.sol +++ b/test/ERC721ACH.t.sol @@ -1,6 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.15; + +import "forge-std/console.sol"; import {Vm} from "forge-std/Vm.sol"; import {DSTest} from "ds-test/test.sol"; import {ERC721ACHMock} from "./utils/ERC721ACHMock.sol"; @@ -144,4 +146,43 @@ contract ERC721ACHTest is DSTest { address(erc721Mock.isApprovedForAllHook()) ); } + + function test_gasEstimateForSingleMint() public { + address buyer = address(0x1111); + console.logString( + "=====================gas estimation for minting single NFT==========================" + ); + uint originGasLeft; + uint gasDelta; + originGasLeft = gasleft(); + erc721Mock.mint(buyer, 1); + gasDelta = originGasLeft - gasleft() - 100; + console.log("gasDelta: %d", gasDelta); + } + + function test_gasEstimateForMint2NFTs() public { + address buyer = address(0x1111); + console.logString( + "=====================gas estimation for minting 2 NFT==========================" + ); + uint originGasLeft; + uint gasDelta; + originGasLeft = gasleft(); + erc721Mock.mint(buyer, 2); + gasDelta = originGasLeft - gasleft() - 100; + console.log("gasDelta: %d", gasDelta); + } + + function test_gasEstimateForMint3NFTs() public { + address buyer = address(0x1111); + console.logString( + "=====================gas estimation for minting 3 NFT==========================" + ); + uint originGasLeft; + uint gasDelta; + originGasLeft = gasleft(); + erc721Mock.mint(buyer, 3); + gasDelta = originGasLeft - gasleft() - 100; + console.log("gasDelta: %d", gasDelta); + } }