From cdb7292a71dd5977166ce7189c19bc6f9924ae29 Mon Sep 17 00:00:00 2001 From: SevenSwen Date: Tue, 28 Mar 2023 17:42:58 +0700 Subject: [PATCH] remove @skip-on-coverage flag --- .solcover.js | 4 ---- hardhat.config.ts | 6 ++++++ test/contracts/StringUtil.test.ts | 7 ++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.solcover.js b/.solcover.js index fb4b6d44..28dd55c8 100644 --- a/.solcover.js +++ b/.solcover.js @@ -25,8 +25,4 @@ module.exports = { skipFiles: [ 'mocks', 'tests', 'interfaces', ], - mocha: { - grep: "@skip-on-coverage", - invert: true - }, } diff --git a/hardhat.config.ts b/hardhat.config.ts index 94612e97..ba52a069 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -10,6 +10,12 @@ import networks from './hardhat.networks'; dotenv.config(); +declare module 'hardhat/types/runtime' { + interface HardhatRuntimeEnvironment { + __SOLIDITY_COVERAGE_RUNNING?: boolean; + } +} + const config: HardhatUserConfig = { solidity: { version: '0.8.15', diff --git a/test/contracts/StringUtil.test.ts b/test/contracts/StringUtil.test.ts index 8d373184..89757bf4 100644 --- a/test/contracts/StringUtil.test.ts +++ b/test/contracts/StringUtil.test.ts @@ -1,6 +1,7 @@ import { expect } from '../../src/prelude'; import { loadFixture } from '@nomicfoundation/hardhat-network-helpers'; import { ethers } from 'hardhat'; +import hre from 'hardhat'; describe('StringUtil', function () { const uint256TestValue = '0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'; @@ -62,7 +63,7 @@ describe('StringUtil', function () { } }); - describe('Gas usage @skip-on-coverage', function () { + describe('Gas usage', function () { it('Uint 256', () => testGasUint256(uint256TestValue, 834)); it('Uint 256 naive', () => testGasNaiveUint256(uint256TestValue, 16277)); @@ -92,21 +93,25 @@ describe('StringUtil', function () { it('Single byte naive', () => testGasNaiveBytes(singleByte, 988)); async function testGasUint256(value: string, expectedGas: number) { + if (!hre.__SOLIDITY_COVERAGE_RUNNING) return; const { stringUtilTest } = await loadFixture(deployStringUtilTest); await stringUtilTest.toHex(value, expectedGas); } async function testGasBytes(value: string, expectedGas: number) { + if (!hre.__SOLIDITY_COVERAGE_RUNNING) return; const { stringUtilTest } = await loadFixture(deployStringUtilTest); await stringUtilTest.toHexBytes(value, expectedGas); } async function testGasNaiveUint256(value: string, expectedGas: number) { + if (!hre.__SOLIDITY_COVERAGE_RUNNING) return; const { stringUtilTest } = await loadFixture(deployStringUtilTest); await stringUtilTest.toHexNaive(value, expectedGas); } async function testGasNaiveBytes(value: string, expectedGas: number) { + if (!hre.__SOLIDITY_COVERAGE_RUNNING) return; const { stringUtilTest } = await loadFixture(deployStringUtilTest); await stringUtilTest.toHexNaiveBytes(value, expectedGas); }