I currently have this solc version:
$ solc --version
solc, the solidity compiler commandline interface
Version: 0.5.10+commit.5a6ea5b1.Linux.g++
And my truffle.config.js has this compilers section:
compilers: {
solc: {
version: "native",
settings: {
optimizer: {
enabled: false,
runs: 200
}
}
}
}
But, when running $ npx solidity-coverage, it uses another version?
$ npx solidity-coverage
...
Compiling your contracts...
===========================
...
> Artifacts written to /.../build/contracts
> Compiled successfully using:
- solc: 0.5.8+commit.23d335f2.Emscripten.clang
...
Runnning truffle test uses the correct (native) version. Is there some configuration that I am missing?
@meyer1994 Do you have a coverage network listed in your truffle-config.js as shown in the README?
SC loads the truffle config and if it doesn't see a coverage network it runs the tests with its own bare bones truffle config which uses the Truffle defaults.
You don't have to launch a client or anything, just list that network.
@meyer1994 Any luck with this?
Sorry about the late response.
You were right. Creating coverage network fixed it. Partially. Weirdly, it generates an error during tests that does not happen when running truffle test. When I arrive home I will post the error here.
Now about the first fix. Shouldn't the truffle-config.js compilers section have precedence over the default value of this package?
@meyer1994
Shouldn't the truffle-config.js compilers section have precedence over the default value of this package?
Yes, it should. Right now the coverage tool has a very awkward integration with Truffle - it was initially built around Truffle 3 and does everything 'from outside'. These configuration problems should be resolved in the next version which will be written as a Truffle plugin.
@meyer1994 I've edited the README to make it clear that adding a coverage network is a default installation requirement.
Closing since SC does handle the compiler correctly when a network is defined. Feel free to describe your failing test problem in this thread though...