Closed alex-murashkin closed 5 years ago
I'm running truffle 5.0.0-beta.2
and getting compilation errors on some solc 0.5.x
specific code when executing solidity-coverage
.
I am keen to know if support for the new solc version is currently in the pipeline?
For a simple/small contract, I'm able to get coverage working https://github.com/mstack/bootcamp-blockchain-smartcontracts/
See Lab 2
& Lab 2 - Completed
(Note the truffle-config.js and .solcover.js files for some detail.
However for a bigger complexer contract, I still get a lot of errors.
Couple of issues I've encountered and fixed:
Disconnecting from testrpc
while running migrations: for some reason this happens when migrations are longer than ~150 lines, just split up any large migration into multiple small migrations.
calldata
storage specifier giving a syntax error: I've opened a PR at https://github.com/sc-forks/solidity-parser/pull/17 for this. You should just be able to copy accross the changes to node_modules/solidity-parser-sc
until this is merged/fixed
Truffle 5.0.0 now allows you to specify the version of solc you want to use to compile your contracts. This works with the default test runner, but not with solidity-coverage (which doesn't use the same test runner in truffle-compile).
It does not work with 5.0.0 for contracts which require solc 0.4.x.
See https://travis-ci.org/alfabc/braided/builds/471619698#L774
Thanks everyone. Sharing the following workaround that has worked for me for "truffle": "5.0.0-beta.2"
and "solidity-coverage": "0.5.4",
.
.solcover.js:
module.exports = {
compileCommand: "cp ../truffle-coverage.js ./truffle.js && truffle compile",
testCommand: "cp ../truffle-coverage.js ./truffle.js && truffle test",
...
};
truffle-coverage.js:
module.exports = {
compilers: {
solc: {
optimizer: {
enabled: true,
runs: 200
},
version: "0.4.25"
}
},
networks: {
development: {
host: "localhost",
network_id: "*",
port: 7545,
gas: 0xfffffffffff,
gasPrice: 0x01
}
}
};
Run: ./node_modules/.bin/solidity-coverage
IIRC, the "cp" step was necessary because by default, the compilers
section isn't included in the generated truffle config file. I may have missed/forgotten some details as it was last year but that's the gist of it :)
Hi, it wasn't supported. I was using solidity 0.5.x and truffle v5 and was not working. I did try to fix it and looks like it's working, at least with the project I was trying it started to work. You can see here the changes https://github.com/sc-forks/solidity-coverage/pull/311. Write some comment if you want :+1:
As a temporary fix, copy https://raw.githubusercontent.com/maxsam4/solidity-parser/solidity-0.5/build/parser.js to node_modules/solidity-parser-sc/build/parser.js
As I am doing in the truffle-5 branch for polymath-core, you may configure your CI to replace this file automatically using
curl -o node_modules/solidity-parser-sc/build/parser.js https://raw.githubusercontent.com/maxsam4/solidity-parser/solidity-0.5/build/parser.js
Waiting for @cgewecke to be active once again and merge https://github.com/sc-forks/solidity-parser/pull/18 and 17.
But is your PR supporting truffle v5, solidity 0.5.x and using web3.js-1.0.0-beta.x ?
You can try this but its not official, I use the code of @maxsam4 and @angus-hamill, add my fork in your package.json
"solidity-coverage": "rotcivegaf/solidity-coverage"
Execute with ./node_modules/.bin/solidity-coverage
or
npm install -g "rotcivegaf/solidity-coverage"
and solidity-coverage
in a terminal
Works with calldata and address payable RCN-circle-ci
Awesome, but what I see here is a bunch of forks. Can we ask someone to start doing something?
I believe this pr is https://github.com/sc-forks/solidity-coverage/pull/311.
Hasn't been touched in 2 weeks though.
I believe this pr is #311.
Hasn't been touched in 2 weeks though.
This PR actually fixes the problem, I've been using it for a while. The only thing failing is the tests because they are using old stuff, for example, very old examples of code from open zeppelin.
I have a lot more work to do so instead of just being here spending time for maybe nothing I decided to get in touch with truffle team. They know that this is not being maintained and they want to add coverage to their tests, but they might not use this framework.
This is the reason I gave up about it. It's too much work for nothing. Sorry to disappoint you. One thing I'm sure is that what is said on the PR #311 is working. Might need some changes, but so far, for me is working well.
For those interested in this issue, I would be interested in any peculiar results or behaviour you found when trying to use the leapdao
branch in this repository, which should work. Note that it assumes solidity ^0.5.3 - for anyone wishing to use Truffle 5 with solidity 0.4.x, you should try setting your compiler version manually in truffle.js
, but I have not tested that functionality at all, so there may be dragons.
0.6.0
The package.json currently specifies Truffle 4 https://github.com/sc-forks/solidity-coverage/blob/master/package.json#L49
Does
solidity-coverage
work with projects created usingtruffle 5.0.0
?