Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    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).
    Adrian Li
    @adrianmcli
    awesome, thanks @cgewecke
    Travis Mathis
    @travisdmathis

    morning, i'm trying to run coverage against my tests and getting a runtimeerror

     1) PanDAO Contract Network
           "before each" hook:
         Uncaught RuntimeError: abort(Error: Method [object Object] not supported.). Build with -s ASSERTIONS=1 for more info.
          at process.abort (.coverage_cache/compilers/soljson-v0.6.6+commit.6c089d02.js:1:14382)
          at process.emit (node_modules/@nomiclabs/buidler/node_modules/source-map-support/source-map-support.js:495:21)
          at process.emit (node_modules/ganache-cli/node_modules/source-map-support/source-map-support.js:465:21)
          at process.object.process.function.process.on.process.emit (node_modules/ganache-cli/build/ganache-core.node.cli.js:37:31967)
          at process.emit (node_modules/source-map-support/source-map-support.js:465:21)
          at emitPromiseRejectionWarnings (internal/process/promises.js:140:18)
          at process._tickCallback (internal/process/next_tick.js:69:34)
    beforeEach(async () => {
        [agent, address1, address2] = await bre.getSigners();
    
        await deployments.fixture();
    
        // setup needed contracts
        Manager = await deployments.get("Manager");
        manager = new ethers.Contract(Manager.address, Manager.abi, agent);
    
        EternalStorage = await deployments.get("EternalStorage");
        eternalStorage = new ethers.Contract(
          EternalStorage.address,
          EternalStorage.abi,
          agent
        );
    
        MockToken = await bre.getContractFactory("Token");
        mockToken = await MockToken.deploy();
        await mockToken.deployed();
      });

    however tests pass fine when just running tests;

    All contracts have already been compiled, skipping compilation.
    
    
      PanDAO Contract Network
        Manager Contract
          ✓ Manager is stored in EternalStorage
          ✓ Can get contract address by contract name
          ✓ Agent owns deployed Manager contract
          ✓ Can create an Insurance Pool if it doesn't exist (442ms)
          ✓ Fails to create Insurance Pool if it already exists (269ms)
          ✓ Fails to create an Insurance Pool if not Agent
    
    
      6 passing (2s)
    solidity-coverage 0.7.5
    luongnt95
    @luongnt95
    hi guys!
    this is my config in .solcover.js
    module.exports = {
      providerOptions: {
        allowUnlimetedContractSize: true,
        gasLimit: 0xfffffffffff,
        logger: console,
        port: 9545,
        fork: MAINNET_NODE_URL,
        network_id: 1,
        unlocked_accounts: [
          '0xd8f8a53945bcfbbc19da162aa405e662ef71c40d', // MLN whale
          '0x3eb01b3391ea15ce752d01cf3d3f09dec596f650', // KNC whale
          '0xa57bd00134b2850b2a1c55860c9e9ea100fdd6cf', // ZRX reserve operator
          '0xBE0eB53F46cd790Cd13851d5EFf43D12404d33E8', // ZRX whale
          '0x7D3455421BbC5Ed534a83c88FD80387dc8271392', // ZRX Governor contract
        ],
        default_balance_ether: startingBalance,
        accounts: [ // TODO: is this array redundant?
          {
            secretKey: PRIV_KEY_1,
            balance: startingBalance,
          }, {
            secretKey: PRIV_KEY_2,
            balance: startingBalance,
          }, {
            secretKey: PRIV_KEY_3,
            balance: startingBalance,
          },
        ],
        }
    };
    luongnt95
    @luongnt95
    and i got this error:
    Error:  *** Deployment Failed ***
    
    "EngineAdapter" ran out of gas (using a value you set in your network config or deployment parameters.)
       * Block limit:  17592186044415 (0xfffffffffff)
       * Gas sent:     17592186044415 (0xfffffffffff)
    
        at ./node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:364:1
        at process._tickCallback (internal/process/next_tick.js:68:7)
    Truffle v5.1.25 (core: 5.1.25)
    Node v10.18.1
    i'm using forked chain for my tests and and they all work fine but when i use sol-coverage i can't deploy my contracts with above errors even with 2 options in my .solcover.js config:
    allowUnlimetedContractSize: true,
    gasLimit: 0xfffffffffff,
    @cgewecke Could you please investigate this issue?
    cgewecke
    @cgewecke
    @luongnt95 This might have to do with using the fork option and the way Truffle maps accounts in the migrations. Can you see if adding default_balance_ether: 10000000 to the providerOptions in solcover.js makes any difference?
    Can you also try removing the gasLimit param altogether? solidity-coverage sets that to an appropriate value automatically.
    @luongnt95 Is your project open-source? If it's on github and neither of those work I could take a look.
    luongnt95
    @luongnt95
    @cgewecke i removed all the config that you mentioned and it makes no difference
    It's an open-source project. You can look at it here: https://github.com/melonproject/protocol/tree/chore/solidity-coverage
    cgewecke
    @cgewecke
    @luongnt95 Ah ok, I see. Your project is very differently organized than the typical Truffle project. I will take a look today...
    cgewecke
    @cgewecke
    @luongnt95 I looked and tbh it's really complicated. The part of your coverage script which shell execs truffle is not really going to work. If you have run your tests against a forked ganache I think you will need to do a bunch of work using truffle deployment modules programatically. I'm sorry.
    I tried to run the tests via mainnet infura but it just hangs after compilation (before deployment).
    cgewecke
    @cgewecke
    You've labeled the build_directory in your Truffle config out rather than build. So temp should be out as well.
    Cyril Lapinte
    @sirhill
    Hello, I am looking to set up a monorepo directory with solidity-coverage and got the following error: solidity-coverage listed as a plugin, but not found in global or local node modules
    Is there some options to let truffle lookup what's needed in the workspace node_modules rather than the module's one ?
    I think, I've found the reason why: -) ... It's a truffle plugin issue as referenced here: trufflesuite/truffle#2409
    Cyril Lapinte
    @sirhill
    Btw, if someone else ask the same question. Adding a symlink in the submodule node_modules directory solve the issue. I've commented truffle issue about it.
    cgewecke
    @cgewecke
    Thanks @sirhill!
    Célio Rodrigues
    @celioggr
    Does instrumentation works for solidity versions like 0.4.15?
    I'm geeting this error when trying to run coverage on a contract
     ParserError: Expected token LBrace got reserved keyword 'Pure'
    function coverage_0x294213b5(bytes32 c__0x294213b5) public pure {}