Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test-hevm fails but test-ethrun pass with contract calling library #34

Closed
mbrock opened this issue Jun 13, 2018 · 7 comments
Closed

test-hevm fails but test-ethrun pass with contract calling library #34

mbrock opened this issue Jun 13, 2018 · 7 comments

Comments

@mbrock
Copy link
Contributor

mbrock commented Jun 13, 2018

Issue by alext234
Wednesday Mar 14, 2018 at 09:11 GMT
Originally opened as dapphub/dapp#82


With the following simple test code:

//WithLib.sol
pragma solidity ^0.4.21;

library MyLib {

	function libFunc(string s) public pure returns(uint) {
		return uint(keccak256(s));
	}
}

contract WithLib {
	
	function myFunc(string s) public pure returns(uint) {
		return MyLib.libFunc(s);
	}
}

And

//WithLib.t.sol
pragma solidity ^0.4.21;

import "ds-test/test.sol";

import "./WithLib.sol";

contract WithLibTest is DSTest {
    WithLib lib;

    function setUp() public {
        lib = new WithLib();
    }

    function test_myFunc() {
	lib.myFunc('a1');
    }
}

dapp test-ethrun passes but dapp test-hevm fails with out of gas (at the place when it calls the library)

Failure: test_myFunc
  
  src/WithLib.t.sol:WithLibTest
   ├╴constructor
   ├╴initialize test
   │  └╴create WithLib (src/WithLib.t.sol:11)
   └╴test_myFunc()
      ├╴call WithLib::myFunc(string)("a1") (src/WithLib.t.sol:15)
      │  └╴error OutOfGas 0xfbffffffefbd 0xfbfffffff279 (src/WithLib.sol:13)
      └╴error Revert (src/WithLib.t.sol:15)

@ggrieco-tob
Copy link
Contributor

This is still failing in hevm 0.24. Additionally, using the following simple test code:

pragma solidity ^0.4.21;

library Lib{
    struct Storage{
        uint val;
    }

    function set(Storage storage st) public {
        st.val = 1;
    }
}

and

pragma solidity ^0.4.21;

import "ds-test/test.sol";

import "./Test.sol";

contract TestTest is DSTest {
    using Lib for Lib.Storage;
    Lib.Storage st;

    function setUp() public {
       st.set();
    }

    function testFail_basic_sanity() public {
        assertTrue(false);
    }

    function test_basic_sanity() public {
        assertTrue(true);
    }
}

All the tests will fail with VMError. For instance:

test test_basic_sanity() (src/Test.t.sol:TestTest)
 ├╴constructor                                    
 ├╴initialize test                                
 └╴test_basic_sanity()                            
    └╴error BadJumpDestination (src/Test.t.sol:19)

@rainbreak
Copy link
Member

Thanks for the simple example. This does appear broken somehow. Can you confirm your solc version?

@ggrieco-tob
Copy link
Contributor

Sure, I'm using:

$ solc --version
solc, the solidity compiler commandline interface
Version: 0.4.25+commit.59dbf8f1.Linux.g++

@mbrock
Copy link
Contributor Author

mbrock commented Feb 18, 2019

Thanks. This turns out to be an error in Hevm's gas semantics for delegatecalls, and also likely an error in the yellow paper's definition of delegatecall. We'll patch it and make a new release after a bit more investigation.

@rainbreak
Copy link
Member

fixed by #158

@rainbreak
Copy link
Member

@ggrieco-tob if there are still issues please let us know

@ggrieco-tob
Copy link
Contributor

I will be happy to test it, but I'm having trouble to install it from source (using stack). Do you know when this new release will be added into stackage?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants