sc-forks / solidity-coverage

Code coverage for Solidity smart-contracts
MIT License
977 stars 264 forks source link

Solcover giving binary (100% or 0) results on OpenST-Protocol. #267

Closed noslav closed 6 years ago

noslav commented 6 years ago

Running solcover with the following packages on - develop of https://github.com/OpenSTFoundation/openst-protocol.git

name: openst-protocol, version: 0.9.1, description: , devDependencies: { abi-decoder: 1.0.9, assert: 1.4.1, bignumber.js: 4.1.0, ganache-cli: 6.1.0, keccak: 1.4.0, rlp: 2.1.0, solidity-coverage: ^0.5.5, solparse: 2.2.5, truffle: 4.1.8, web3: 1.0.0-beta.33 author: OpenST Foundation Ltd., license: Apache v2.0

results in binary reports - thereby giving unclear directions on test line coverage, kindly point out where the process could be going wrong.

File % Stmts % Branch % Funcs % Lines Uncovered Lines
contracts/ 0 0 0 0
BrandedToken.sol 0 0 0 0 ... 152,154,156
BytesLib.sol 0 0 0 0 ... 165,167,171
Core.sol 0 0 0 0 ... 326,328,330
CoreInterface.sol 100 100 100 100
CoreMock.sol 0 100 0 0 39,53,70
EIP20Interface.sol 100 100 100 100
EIP20Token.sol 0 100 0 0 ... 208,221,223
EIP20TokenMock.sol 0 100 0 0 57,77,94,111
Gateway.sol 0 0 0 0 ... 391,394,396
Hasher.sol 0 100 0 0 58,95,131,156
MerklePatriciaProof.sol 0 0 0 0 ... 191,192,196
MerklePatriciaProofTest.sol 0 100 0 0 33,55
OpenSTUtility.sol 0 0 0 0 ... 741,757,759
OpenSTUtilityInterface.sol 100 100 100 100
OpenSTUtilityMock.sol 0 0 0 0 ... 72,73,75,76
OpenSTValue.sol 0 0 0 0 ... 672,673,675
OpenSTValueInterface.sol 100 100 100 100
OpenSTValueMock.sol 0 0 0 0 ... 93,94,96,97
OpsManaged.sol 0 0 0 0 ... 163,165,167
Owned.sol 0 0 0 0 ... 106,108,110
ProofLib.sol 0 100 0 0 ... 57,58,84,86
ProofLibTest.sol 0 0 0 0 49,78,86
ProtocolVersioned.sol 0 0 0 0 ... 192,194,203
ProtocolVersionedMock.sol 0 100 0 0 41
RLP.sol 0 0 0 0 ... 503,504,505
RLPEncode.sol 0 0 0 0 ... 70,71,73,74
RLPTest.sol 0 0 0 0 ... 68,69,85,86
Registrar.sol 0 100 0 0 ... 229,272,304
STPrime.sol 0 0 0 0 ... 166,192,194
STPrimeConfig.sol 100 100 100 100
SafeMath.sol 0 0 0 0 ... 81,93,95,97
SafeMathMock.sol 0 100 0 0 55,69,83
SimpleStake.sol 0 0 0 0 ... 9,91,93,113
TestUtils.sol 0 100 0 0 47
UtilityTokenAbstract.sol 0 0 0 0 ... 305,307,309
UtilityTokenAbstractMock.sol 0 100 0 0 ... 130,152,173
UtilityTokenInterface.sol 100 100 100 100
Workers.sol 0 0 0 0 ... 158,178,180
WorkersInterface.sol 100 100 100 100
contracts/SimpleToken/ 0 0 0 0
ERC20Interface.sol 100 100 100 100
ERC20Token.sol 0 100 0 0 ... 104,106,108
MockToken.sol 0 0 0 0 30,32,34,36,40
OpsManaged.sol 0 0 0 0 ... 104,106,108
Owned.sol 0 0 0 0 ... 53,54,56,58
SafeMath.sol 0 0 0 0 ... 41,46,48,50
SimpleToken.sol 0 0 0 0 ... ,99,101,103
SimpleTokenConfig.sol 100 100 100 100
contracts/truffle/ 0 0 0 0
Migrations.sol 0 0 0 0 8,12,16,20,21
All files 0 0 0 0

Also one of the errors given during compilation is the following -

~/SimpleToken/openst-protocol/coverageEnv/contracts/OpenSTValue.sol:377:24: CompilerError: Stack too deep, try removing local variables. require(nonces[_redeemer] + 1 == _redeemerNonce);

cgewecke commented 6 years ago

@noslav Thanks for opening, will take a look. At a minimum the contracts need to compile and the tests run correctly before a coverage report can be generated.

There's a another issue reporting this compilation error at #248

noslav commented 6 years ago

thanks for your response @cgewecke, got solcover running with no compilation warnings or errors on the protocol - but was coming across the issue #109 for which the suggested solution helped, thanks for pointing out the fix! 👍

cgewecke commented 6 years ago

Ok great @noslav - are you getting a report now? If so we will close here and continue to track the stack too deep issue #248.

Also how did the stack too deep resolve itself?

noslav commented 6 years ago

@cgewecke Yes, I was indeed able to generate a nice non-binary report. We can close this issue and track the stack too deep @ #248. I fixed it by removing a require statement that leads to one failing test overall , using truffle test on the entire repo - not using solcover. Also, while running solcover some of the truffle tests on the contracts fail (causing improper reporting for those respective contracts) so I'm trying to fix those at the moment by checking if the versions of solc, truffle etc being used by solcover are the same as the ones being used in the repo truffle testing. If you've come across something similar kindly let me know. Thanks again!

cgewecke commented 6 years ago

@noslav solidity-coverage just uses your Truffle, so there shouldn't be any variance there. The main causes of test failures right now are from . . .

noslav commented 6 years ago

@cgewecke everything works great! Generated very helpful reports - will be integrating it for TravisCI soon, config file setup directions were really helpful!!