JoinColony / solcover

Code coverage for solidity
MIT License
64 stars 8 forks source link

cross-contract invoke, test result is not the same with truffle #20

Closed maiffany closed 7 years ago

maiffany commented 7 years ago

Here I come again... I wanna try to test cross-contract invoking, Just like in java: new class A in class B. And I got the two contract.

contract Add{
  function sum(uint x, uint y) returns(uint){
    return x+y;
  }
}
contract Sum{
  function func(uint x, uint y) returns(uint){
    Add add = new Add();
    uint re = add.sum(x,y);
    return re;
  }
}

Because I call Add in Sum, so in the Sum.sol I have to includeAdd contract inside it.

And now I test this contract in truffle with my own ethereum client, it works fine.

image

But with solcover, the result is so weired.

instrumenting  ./../originalContracts/Add.sol
instrumenting  ./../originalContracts/Sum.sol
cp: no such file or directory: ./../originalContracts/Migrations.sol
rm: no such file or directory: ./allFiredEvents
Compiling Add.sol...
Compiling Sum.sol...

  Contract: Sum
    1) should return 5 when add 2 and 3
    > No events were emitted

  Contract: Add
    ✓ should return 5 when add 2 and 3

  1 passing (512ms)
  1 failing

  1) Contract: Sum should return 5 when add 2 and 3:
     AssertionError: sum of 2 and 3 is 5: expected '9.1735649321334958107552852973512799782292704141468709142420585807991067901952e+76' to equal 5
      at /Users/maiffany/testcoverage/test/sum.js:6:14
      at process._tickDomainCallback (internal/process/next_tick.js:129:7)

Done

My test code is in here: https://github.com/maiffany/mytest/tree/master

area commented 7 years ago

I'm sorry to say this is a problem with testrpc, not ~solparse~solcover. There's an issue logged but no movement on it for quite some time. Given I can reproduce the error with an unpatched testrpc, I'm afraid I'm going to close this issue given it's a problem with a dependency that we can't really work around.

maiffany commented 7 years ago

Got it! Thank you anyway!