Skip to content

Code coverage Zero percent when the flag viaIR:true #756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
badrik-pedalsup opened this issue Sep 28, 2022 · 3 comments
Closed

Code coverage Zero percent when the flag viaIR:true #756

badrik-pedalsup opened this issue Sep 28, 2022 · 3 comments

Comments

@badrik-pedalsup
Copy link

my solidity files are to big and are not getting compiled without enabling this flag.

.solcover.js

module.exports = {
    configureYulOptimizer: true,
    skipFiles:["USDC.sol"],
    measureStatementCoverage:true,
};

hardhat.config.js

require("@nomiclabs/hardhat-ethers");
require('hardhat-abi-exporter');
require("@nomiclabs/hardhat-etherscan");
require("@nomicfoundation/hardhat-toolbox");
require('solidity-coverage');
require('hardhat-contract-sizer');

//Require .env
require("dotenv").config({ path: __dirname + "/.env" });

module.exports = {
  defaultNetwork:process.env.NETWORK,
  etherscan: {
    apiKey: process.env.ETHERSCAN_API_KEY,
  },
  networks: {
    rinkeby: {
      url: process.env.RINKEBY_URL,
      accounts: [process.env.ACCOUNT_PRIVATE_KEY],
    },
    goerli: {
      url: process.env.GOERLI_URL,
      accounts: [process.env.ACCOUNT_PRIVATE_KEY],
    },
    hardhat: {
      mining: {
        auto: true,
        interval: [3000, 6000]
      }
    }
  },
  solidity: {
    version: "0.8.16",
    settings: {
      optimizer:{
        "enabled": true,
        "runs": 1, 
      },
      "evmVersion": "istanbul",
      "viaIR": true
    },
  },
  paths: {
    sources: "./contracts",
    tests: "./test",
    cache: "./cache",
    artifacts: "./artifacts"
  },
  mocha: {
    timeout: 20000
  },
  abiExporter: [
    {
      path: './abi/json',
      runOnCompile: true,
      clear: true,
      flat: true,
      only: ['contracts/implementation.sol:ERC20NonTransferable','contracts/factory.sol:FactoryCloneContract','contracts/emitter.sol:Emitter', 'contracts/USDC.sol:USDC'],
      spacing: 2,
      format:'json'
    },
    {
      path: './abi/minimal',
      runOnCompile: true,
      clear: true,
      flat: true,
      only: ['contracts/implementation.sol:ERC20NonTransferable','contracts/factory.sol:FactoryCloneContract','contracts/emitter.sol:Emitter'],
      spacing: 2,
      format:'minimal'
    }
  ],
  plugins: ["solidity-coverage"],
  contractSizer: {
    alphaSort: true,
    disambiguatePaths: false,
    runOnCompile: false,
    strict: true,
    only: [],
  },
}

Output:-

Version
=======
> solidity-coverage: v0.8.2

Instrumenting for coverage...
=============================

> emitter.sol
> factory.sol
> implementation.sol
> proxy.sol

Coverage skipped for:
=====================

> USDC.sol

Compilation:
============

(node:19326) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Compiled 31 Solidity files successfully

Network Info
============
> HardhatEVM: v2.11.2
> network:    hardhat



  Factory Contract testing
    ✔ Deploy factory, proxy, usdc, emitter contract (665ms)
    ✔ Deploy factory contract with invalid USDC address should fail (51ms)
    ✔ Check the owner of factory
    USDC method testing(changeUSDCAddress)
      ✔ Check USDC address
      ✔ Change USDC address (115ms)
      ✔ Change USDC to invalid address should fail
      ✔ Only owner can change the USDC address (95ms)
    Implementation method testing(changeDAOImplementation)
      ✔ Check implementation address
      ✔ Change Implementation address (97ms)
      ✔ Change Implementation to invalid address should fail
      ✔ Only owner can change the implementation address (61ms)
    Create dao method testing(createDAO)
      ✔ Create Dao (70ms)
      ✔ Max should be grater than min in create DAO (49ms)
      ✔ Total raise should be grater than max in create DAO (40ms)
      ✔ Days should be grater than 0 in create DAO (44ms)
      ✔ Owner fee cannot be 100 in create DAO (43ms)
      ✔ Owner address cannot be null in create DAO (40ms)
      ✔ Quorum cannot exceed 100 in create DAO method (44ms)
      ✔ Threshold cannot exceed 100 in create DAO method (47ms)
      ✔ Check owner address
      ✔ Check DAO config (82ms)

  Implementation Contract (DAO testing)
    Update min max deposit(updateMinMaxDeposit)
      ✔ Check the min max deposit amount (289ms)
      ✔ Change the min max deposit per user (44ms)
      ✔ Only admin can change the min max deposit per user
      ✔ Max should be grater than min in change change min max deposit per user
    Update owner fee(updateOwnerFee)
      ✔ check the owner fee
      ✔ Change the owners fee
      ✔ Owner fee cannot be grater than or equal to 100
      ✔ Only owner can change the owner fee
    Close deposit (closeDeposit)
      ✔ close deposit
      ✔ Cannot close deposit if it's already closed (38ms)
      ✔ Only admin can close deposit
    Start deposit (startDeposit)
      ✔ Start deposit (61ms)
      ✔ Start deposit with raise amount equal to 0 should fail
      ✔ Start deposit with days equal to zero should fail (41ms)
      ✔ Total raise amount should be grater than or equal to previous raise amount (52ms)
      ✔ Start deposit should fail if deposit is already running
      ✔ Only admin can start deposit
    Testing Deposit function(deposit)
      ✔ Try Deposit with fees in USDC (77ms)
      ✔ Try amount less than min balance (39ms)
      ✔ Try amount grater than max balance (39ms)
      ✔ Try depositing another token than usdc (77ms)
      ✔ try deposit if amount has exceed total raise amount (69ms)
      ✔ try deposit into DAO where fees in GT token (89ms)
    Execute proposal(updateProposalAndExecution)
      ✔ Airdrop token (149ms)
      ✔ Mint GT tokens (61ms)
      ✔ Update governor settings (58ms)
      ✔ Update raise amount (55ms)
      ✔ Send custom token (71ms)


  49 passing (3s)

---------------------|----------|----------|----------|----------|----------------|
File                 |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
---------------------|----------|----------|----------|----------|----------------|
 contracts/          |        0 |        0 |        0 |        0 |                |
  emitter.sol        |        0 |        0 |        0 |        0 |... 1,95,99,103 |
  factory.sol        |        0 |        0 |        0 |        0 |... 72,78,80,81 |
  implementation.sol |        0 |        0 |        0 |        0 |... 611,618,625 |
  proxy.sol          |        0 |      100 |        0 |        0 |    34,35,41,42 |
---------------------|----------|----------|----------|----------|----------------|
All files            |        0 |        0 |        0 |        0 |                |
---------------------|----------|----------|----------|----------|----------------|

> Istanbul reports written to ./coverage/ and ./coverage.json
@laraschke
Copy link

laraschke commented Dec 6, 2022

Same problem on my side. The compilation results in "Stack too deep" without "viaIR: true". Setting viaIR to true compiles the contracts and runs the test cases but shows 0% test coverage for all files.

@hung-native
Copy link

same here

@cgewecke
Copy link
Member

Tracking this in #715

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants