It appears that solidity-coverage is compiling with a different compiler version that Truffle is using. I'm getting the following error, where it's using 0.5.0 instead:
SyntaxError: Source file requires different compiler version (current compiler is 0.5.0+commit.1d4f565a.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
My truffle.js specifies 0.5.2:
module.exports = {
networks: {
development: { // Ganache
host: '127.0.0.1',
port: 8545,
network_id: '*', // 5777
},
},
compilers: {
solc: {
version: '0.5.2',
optimizer: {
enabled: true,
runs: 20,
},
},
},
};
I'm using:
Truffle v5.0.1 (core: 5.0.1)
Solidity - 0.5.2 (solc-js)
Node v8.11.2
solidity-coverage v0.5.11
What am I missing here? Why is solidity-coverage using 0.5.0 instead of 0.5.2?
Fixed by adding a coverage section in truffle.js:
networks: {
development: { // Ganache
host: '127.0.0.1',
port: 8545,
network_id: '*', // 5777
},
coverage: {
host: '127.0.0.1',
port: 8545,
network_id: '*',
},
}
Most helpful comment
Fixed by adding a
coveragesection intruffle.js: