From 1d7a2878f5be082d1f5b65ea4b7f64c6a00bb77c Mon Sep 17 00:00:00 2001 From: Max Vasin Limsukhawat Date: Fri, 17 May 2024 21:01:09 -0600 Subject: [PATCH] fix hardhat coverage --- .solcover.ts | 7 +++++++ hardhat.config.ts | 4 ++++ package.json | 2 +- test/zkSync/erc20ChainlinkPaymaster.test.ts | 2 +- test/zkSync/erc20PythPaymaster.test.ts | 2 +- 5 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 .solcover.ts diff --git a/.solcover.ts b/.solcover.ts new file mode 100644 index 00000000..ffef0036 --- /dev/null +++ b/.solcover.ts @@ -0,0 +1,7 @@ +module.exports = { + skipFiles: ['upgradeables/marketplace/direct-listings-addon/DirectListingsAddon.sol'], + mocha: { + grep: '@skipCoverage', // Use a tag like @skipCoverage in your test descriptions + invert: true, // This will run tests not matching the grep expression + }, +}; diff --git a/hardhat.config.ts b/hardhat.config.ts index 64e86934..03f913fe 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -4,6 +4,7 @@ import { HardhatUserConfig } from 'hardhat/config'; import '@nomicfoundation/hardhat-toolbox'; import '@typechain/hardhat'; import 'hardhat-contract-sizer'; +import 'solidity-coverage'; // This adds support for typescript paths mappings import 'tsconfig-paths/register'; import '@openzeppelin/hardhat-upgrades'; @@ -27,6 +28,9 @@ const config: HardhatUserConfig = { optimizer: { enabled: true, runs: 1, + details: { + yul: true, + }, }, viaIR: true, }, diff --git a/package.json b/package.json index c7cf5973..de6a87fa 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "solhint": "solhint ./contracts/**/*.sol", "format": "yarn prettier -w ./deploy/**/*.ts ./tasks/**/*.ts ./tests/**/*.ts ./helpers/**/*.ts contracts/**/*.sol ", "format:check": "yarn prettier -c ./deploy/**/*.ts ./tasks/**/*.ts ./tests/**/*.ts ./helpers/**/*.ts ./contracts/**/*.sol ", - "coverage": "pnpm dlx hardhat coverage", + "coverage": "TS_NODE_TRANSPILE_ONLY=true SOLIDITY_COVERAGE=true hardhat coverage --solcoverjs .solcover.ts", "coverage:foundry": "forge coverage --report lcov && genhtml lcov.info --branch-coverage --output-dir coverage", "generate:types": "pnpm dlx hardhat typechain" }, diff --git a/test/zkSync/erc20ChainlinkPaymaster.test.ts b/test/zkSync/erc20ChainlinkPaymaster.test.ts index c2c62c8a..bc67dba4 100644 --- a/test/zkSync/erc20ChainlinkPaymaster.test.ts +++ b/test/zkSync/erc20ChainlinkPaymaster.test.ts @@ -13,7 +13,7 @@ dotenv.config(); // load wallet private key from env file const PRIVATE_KEY = process.env.PRIVATE_KEY || '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'; -describe('ERC20ChainlinkPaymaster', function () { +describe('@skipCoverage ERC20ChainlinkPaymaster', function () { let provider: Provider; let minterAccount: Wallet; let deployer: Deployer; diff --git a/test/zkSync/erc20PythPaymaster.test.ts b/test/zkSync/erc20PythPaymaster.test.ts index 4f26bf77..25a1c206 100644 --- a/test/zkSync/erc20PythPaymaster.test.ts +++ b/test/zkSync/erc20PythPaymaster.test.ts @@ -13,7 +13,7 @@ dotenv.config(); // load wallet private key from env file const PRIVATE_KEY = process.env.PRIVATE_KEY || '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'; -describe('ERC20PythPaymaster', function () { +describe('@skipCoverage ERC20PythPaymaster', function () { let provider: Provider; let minterAccount: Wallet; let deployer: Deployer;