Commit 438bc78a authored by Maurelian's avatar Maurelian Committed by smartcontracts

chore: Remove unused test helpers

parent fa5ef7a0
---
'@eth-optimism/contracts': patch
---
Remove unused gas testing utils
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract Helper_GasMeasurer {
function measureCallGas(address _target, bytes memory _data) public returns (uint256) {
uint256 gasBefore;
uint256 gasAfter;
uint256 calldataStart;
uint256 calldataLength;
assembly {
calldataStart := add(_data, 0x20)
calldataLength := mload(_data)
}
bool success;
assembly {
gasBefore := gas()
success := call(gas(), _target, 0, calldataStart, calldataLength, 0, 0)
gasAfter := gas()
}
require(success, "Call failed, but calls we want to measure gas for should succeed!");
return gasBefore - gasAfter;
}
}
import { ethers } from 'hardhat'
import { Contract, Signer } from 'ethers'
export class GasMeasurement {
GasMeasurementContract: Contract
public async init(wallet: Signer) {
this.GasMeasurementContract = await (
await (await ethers.getContractFactory('Helper_GasMeasurer')).deploy()
).connect(wallet)
}
public async getGasCost(
targetContract: Contract,
methodName: string,
methodArgs: Array<any> = []
): Promise<number> {
const gasCost: number =
await this.GasMeasurementContract.callStatic.measureCallGas(
targetContract.address,
targetContract.interface.encodeFunctionData(methodName, methodArgs)
)
return gasCost
}
}
...@@ -5,4 +5,3 @@ export * from './utils' ...@@ -5,4 +5,3 @@ export * from './utils'
export * from './codec' export * from './codec'
export * from './test-runner' export * from './test-runner'
export * from './trie' export * from './trie'
export * from './gas'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment