Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Cyril Lapinte
    @sirhill
    Awesome and it's all fine then. :-)
    cgewecke
    @cgewecke
    Will add abstract to that list.... SC uses as JS solidity parser whose grammar needs a bunch of updates.
    Cyril Lapinte
    @sirhill
    Thanks a lot for the amazing work!
    cgewecke
    @cgewecke
    And there are a bunch of other tools like linters that rely on it...hopefully the fixes will get written and published shortly. Thanks so much!
    But TLDR; solc 0.6.0 won't be supported for a bit.
    Elena Gesheva
    @elenadimitrova
    @cgewecke @DimitarSD @Perseverance guys there were conversations about etherlime working with solidity-coverage before. Do you currently support this scenario? I am hitting a lot of issues trying to either use the etherlime coverage functionality (which utilises 0x coverage tool under the bonnet) or use the solidity-coverage on top of an etherlime project. I don’t get why the tools have to be so tied in with the test/deploy framework underneath, i.e. solidity-coverage with truffle and etherlime with 0x coverage
    cgewecke
    @cgewecke
    Hi @elenadimitrova - solidity-coverage's newest version (0.7.0) tries to address the platform dependence problem by publishing an API. There's documentation for it here: https://github.com/sc-forks/solidity-coverage/blob/master/docs/api.md#solidity-coverage-api
    I don’t get why the tools have to be so tied in with the test/deploy framework underneath, i.e. solidity-coverage with truffle and etherlime with 0x coverage
    cgewecke
    @cgewecke
    This problem is mostly about each dev stack managing contract sources, build artifacts and provider setting differently. The new design assumes they'll all have their own interface for this and some kind script (or plugin) needs to be written around the core pieces of SC to glue everything together.
    cgewecke
    @cgewecke
    This should be reasonably simple - there are a couple example plugins (for Truffle and Buidler) in the repo and am very happy to help any non-truffle tools to get something working. One of SCs design goals is to be as platform-neutral as possible.
    Elena Gesheva
    @elenadimitrova
    Thanks @cgewecke , I’ll check out the new version
    cgewecke
    @cgewecke
    @elenadimitrova If you run into difficulty and have a sample etherlime project, please just lmk - will look at it. It would be nice to develop a simple example of using the API for cases like theirs.
    Elena Gesheva
    @elenadimitrova
    @cgewecke I’m trying it with https://github.com/argentlabs/argent-contracts which is using etherlime but having problems with the built in coverage there which uses 0x coverage solution. fyi I’ve logged that issue separtely here LimeChain/etherlime#298
    cgewecke
    @cgewecke
    @elenadimitrova Ah great! I'll take a look.
    Elena Gesheva
    @elenadimitrova
    @cgewecke actually it seems that etherlime might be swtching across to solidity-coverage soon https://github.com/LimeChain/etherlime/issues/298#issuecomment-573039047
    So don’t worry too much about testing a separate setup, I can hold off a little wait for their upgrade
    cgewecke
    @cgewecke
    @elenadimitrova Ok nice, I will ping that at that issue then.
    UPPPUTURI DUSHYANTH KUMAR REDDY
    @udkreddy

    Hello,
    I am Getting compilation failed error while generation coverage, precisely after instrumentation and truffle compile is working fine
    Error:

    * Line 1, Column 1
      Syntax error: value, object or array expected.
    * Line 1, Column 2
      Extra non-whitespace after JSON value.
    Compilation failed. See above.

    My solidity version is 0.5.7
    Please check this for my truffle-config and .solcover.js https://ethereum.stackexchange.com/questions/79460/compilation-failed-during-instrumentation-of-solidity-coverage
    Could anyone help me if i am doing any mistake in config

    UPPPUTURI DUSHYANTH KUMAR REDDY
    @udkreddy
    *solidity version : 0.5.10
    "solc": "^0.5.10",
    "solidity-coverage": "^0.6.3"
    cgewecke
    @cgewecke
    @udkreddy The only thing I see is that your version is 0.6.3, but you're listing solidity-coverage as a plugin in the truffle config. You could try updating solidity-coverage to latest and looking over the upgrade guide in the README.
    At the moment the only instrumentation faults we know of on 0.7.x are caused by non-unicode characters in the Solidity (like scientific notation or emojis in the natspec comments). And solc 0.6.x.
    If you still have problems, you'll have to link to the code somewhere so we can debug further.
    UPPPUTURI DUSHYANTH KUMAR REDDY
    @udkreddy

    updated solidity-coverage version to 0.7.1 and truffle 5.0.31
    Getting this error now, during compilation after instrumentation

    > solidity-coverage cleaning up, shutting down ganache server
    Error: TypeError: Cannot convert undefined or null to object
        at Object.compile (/home/udkreddy/Dushyanth/NexusMutual/nxm-smart-contracts/node_modules/truffle/build/webpack:/packages/truffle-workflow-compile/legacy/index.js?6101:72:1)
        at <anonymous>

    Find repo here : https://github.com/udkreddy/nxm-smart-contracts/tree/coverage-fix

    cgewecke
    @cgewecke
    @udkreddy Checked out your repo. It looks like we are having a problem instrumenting the version of usingOraclize.sol you're using. Still experimenting (it takes quite a while for your tests to launch) but there is a gist of some changes you could make to get the tests running here:
    cgewecke
    @cgewecke
    @udkreddy Apologies, I see that you need coverage to run on port 8545 because there are web3 calls in some of your tests before blocks...will need to edit that gist a bit. Let me see if I can get a clean test run and then you will have all the changes you need.
    UPPPUTURI DUSHYANTH KUMAR REDDY
    @udkreddy
    Thanks for response @cgewecke ,
    will check making changes per gist
    cgewecke
    @cgewecke

    @udkreddy I haven't been able to get the tests to run to completion - the setup takes a really long time - I don't know if it's due to the coverage tool because I can't get the regular tests to run. If you add a network flag to...

    npx truffle run coverage --network development

    in test.sh, coverage will use 8545 but the before block for the first test just seems to hang. If you omit the network flag, eventually you will see some tests running but some of the before blocks error because they are using the wrong port to make Web3 calls.

    UPPPUTURI DUSHYANTH KUMAR REDDY
    @udkreddy
    My bad, errors in testcases were due to updated truffle version, so need to make changes as per newer version.
    Resolved those errors and now able to run regular testcases, but for coverage getting same error.
    Will check removing web3 calls from testcases.
    UPPPUTURI DUSHYANTH KUMAR REDDY
    @udkreddy
    Thank you,
    Got it working after resolving port issue with web3
    Ashish
    @0xAshish
    @cgewecke how do i run coverage where my tests are using 2 rpc nodes( one ganache and one geth)
    or let's say I am running both RPC externally then how do I ignore internal ganache and point to both external RPC nodes.
    cgewecke
    @cgewecke
    @ashish At the moment it's necessary to be able to run your entire suite on a ganache client. You can use any version you want by specifying it in .solcover.js under the client option (see README for details).
    But the way coverage works is by hooking into the VM of the client and tracking code execution by detecting specific opcodes...it can't be used with geth.
    cgewecke
    @cgewecke
    The current design doesn't use 0xProject's strategy of requesting the execution trace via a provider because that seemed to be unstable for many large projects (the trace can be huge). Instead it listens the JS EVM step directly in memory...
    fluorostani
    @fluorostani

    Having some issues with the parser and Solidity 0.6.3 features.

    It doesn't support structs sitting at the tops of files:

    ParserError: Could not instrument: mycontract.sol. (Please verify solc can compile this file without errors.) extraneous input 'struct' expecting {<EOF>, 'pragma', 'import', 'abstract', 'contract', 'interface', 'library'}
    at Object.parse (.../node_modules/solidity-parser-diligence/dist/index.js:79:11)
    at Instrumenter.instrument (.../node_modules/solidity-coverage/lib/instrumenter.js:63:30)
    at API.instrument (.../node_modules/solidity-coverage/lib/api.js:91:48)
    at plugin (.../node_modules/solidity-coverage/plugins/truffle.plugin.js:76:19)

    And it doesn't support enums being used as keys for mappings:

    ParserError: Could not instrument: mycontract.sol. (Please verify solc can compile this file without errors.) mismatched input 'MyEnum' expecting {'address', 'var', 'bool', 'string', 'byte', Int, Uint, Byte, Fixed, Ufixed}
    at Object.parse (.../node_modules/solidity-parser-diligence/dist/index.js:79:11)
    at Instrumenter.instrument (.../node_modules/solidity-coverage/lib/instrumenter.js:63:30)
    at Instrumenter.instrument (.../node_modules/solidity-coverage/lib/instrumenter.js:63:30)
    at API.instrument (.../node_modules/solidity-coverage/lib/api.js:91:48)
    at plugin (.../node_modules/solidity-coverage/plugins/truffle.plugin.js:76:19)
    cgewecke
    @cgewecke
    @fluorostani Thanks for reporting and for opening issues at the parser!
    Célio Rodrigues
    @celioggr

    I'm trying to check the coverage of an entire ERC20 set of openzeppelin tests. I'm using openzeppelin/test-environment and solidity-coverage v0.7.4 as a plugins in truffle. the tests went fine but I get odd results for coverage.

    Contract | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines
    Context.sol | 0 | 100 | 0 | 0 | 20,24,25 |
    ERC20.sol | 0 | 0 | 0 | 0 |... 217,227,228 |
    ERC20Mock.sol | 0 | 100 | 0 | 0 |... 16,20,24,28 |
    IERC20.sol | 100 | 100 | 100 | 100 | |
    SafeMath.sol | 0 | 0 | 0 | 0 |... 136,153,154

    As you can see, only IERC20 got entirely covered, and ERC20 got nothing despite of this contract being implementation of the interface IERC20. SafeMath should have some coverage as well. Does anyone can explain this? This is my first time using solidity-coverage, any help is much appreciated.

    cgewecke
    @cgewecke
    @celioggr The coverage tool needs to do a custom compilation without optimization and attach a hook into the ganache client before the tests are run. Unless OZ has organized their tooling to execute those steps, coverage won't work. But idk how you've set things up exactly. Do you have a public repo where you're working on this?
    Célio Rodrigues
    @celioggr
    @cgewecke yes I have. Please have a look at https://github.com/celioggr/coverage-testing
    I commented out my changes and how I set things up
    Célio Rodrigues
    @celioggr
    on readme.md
    cgewecke
    @cgewecke
    @celioggr Thanks for that link...the problem is that oz-test-environment spins up it's own ganache client as part of running contract.fromArtifact. It's not using the coverage-enabled instance launched by the truffle plugin. AFAIK they are actively working on their own solidity-coverage integration as part their Q2 improvements: https://github.com/OpenZeppelin/openzeppelin-test-environment/milestone/1
    I didn't see a simple way of telling oz-test-environment to use one client or another, e.g it doesn't look like you could run the tests against a geth development instance either.
    Célio Rodrigues
    @celioggr
    @cgewecke I see...thanks for the link, that explains a lot!! What kind of options do I have here? removing oz-test-environment out of the equation and let "truffle test" do its thing with solidity-coverage? never tried that way
    cgewecke
    @cgewecke
    @celioggr oz-test-environment and Truffle are different...to use Truffle you'd have to modify all the tests to use their contract loading mechanism, e.g: const Token = artifacts.require('Token')
    You might ping OZ and ask them if they have any early work done on their coverage setup and offer to battle test it..idk whether there's work open in a branch over there or not.
    Adrian Li
    @adrianmcli

    @cgewecke Is there any support for people who aren't using Truffle/Buidler at all? I actually just run my own Ganache instance, use Truffle to compile/migrate, and then use Jest as my test-runner.

    How would I configure my setup to be "coverage-enabled"?

    Adrian Li
    @adrianmcli
    I see some relevant discussions here: OpenZeppelin/openzeppelin-test-environment#21
    cgewecke
    @cgewecke
    @adrianmcli Yes, there's an API and an example of a setup using jest at dydx which has a custom script written with it. (Basically a modified version of the script that drives the truffle plugin).