4

I faced a problem: solidity coverage returns that none contract is covered. I have a couple of tests that call these contracts to check specific conditions. As you can see on the images below the functions are exist and tests are passed. Maybe I'm misunderstanding something? Moreover, everything works fine with another project, all versions are the same, all configs +- are the same. Does somebody know what it can be? enter image description here enter image description here enter image description here enter image description here

3
  • 1
    Hey I'm having your same problem. Did you manage to fix that?
    – Allennick
    Apr 25, 2023 at 15:21
  • 1
    Hey @Allennick. In my case, I changed the hardhat config. Set viaIR: false and optimizer.enabled: false.
    – AGJoYy
    Aug 23, 2023 at 20:03
  • @AGJoYy can you share the hardhat config code if possible?
    – pakoray
    Sep 11, 2023 at 20:57

2 Answers 2

1

I had hardhat compilers settings like this before

settings: {
    optimizer: {
        enabled: true,
        runs: 1,
        details: {
            yul: true,
        },
    },
    viaIR: true,
}

and I removed viaIR: true, so I receive

settings: {
    optimizer: {
        enabled: true,
        runs: 1,
        details: {
            yul: true,
        },
    },
}

And this works for me

1

For me, adding the below code in solcover.js worked:

    ...
    configureYulOptimizer: true,
    solcOptimizerDetails: {
        yul: true,
        yulDetails: {
            optimizerSteps: ""
        },
    },
    ...

Solidity: 0.8.19

Hardhat Compiler Settings: {"viaIR":true,"optimizer":{"enabled":true, "details": {"yul": true}}}

However, some tests use higher gas than running tests with the npx hardhat test. So, we might need to change some tests accordingly.

1
  • The latest solidity-coverage version takes care of this issue natively.
    – remedcu
    Mar 6 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.