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

Time travel doesn't work on Ubuntu #176

Open
Pet3ris opened this issue Jan 23, 2020 · 0 comments
Open

Time travel doesn't work on Ubuntu #176

Pet3ris opened this issue Jan 23, 2020 · 0 comments

Comments

@Pet3ris
Copy link

Pet3ris commented Jan 23, 2020

  • Version: 0.2.0b2
  • Python: 3.7
  • OS: X Catalina but the error occurs in the Docker image circleci/mariadb:10-bionic

eth-tester is installed via web3[tester]

What was wrong?

def test_time_travel_doesnt_jump_far_web3():
    web3 = Web3(EthereumTesterProvider())
    MAX_TIMESTAMP = 33040162800
    t0 = web3.eth.getBlock("latest")["timestamp"]
    assert t0 > 0
    ε = 10

    for  in [3 * 10**6, 6 * 10**8, 9 * 10**7, MAX_TIMESTAMP // 2]:
        current_timestamp = web3.eth.getBlock("pending")["timestamp"]
        to_timestamp = current_timestamp + 
        web3.manager.provider.ethereum_tester.time_travel(to_timestamp)
        web3.manager.provider.ethereum_tester.mine_block()
        t1 = web3.eth.getBlock("latest")["timestamp"]
        assert t0 +  <= t1 <= t0 +  + ε

        t0 = t1

This worked on my Mac but failed in my build with:

____________________ test_time_travel_doesnt_jump_far_web3 _____________________

    def test_time_travel_doesnt_jump_far_web3():
        web3 = Web3(EthereumTesterProvider())
        MAX_TIMESTAMP = 33040162800
        t0 = web3.eth.getBlock("latest")["timestamp"]
        assert t0 > 0
        ε = 10
    
        for tΔ in [3 * 10**6, 6 * 10**8, 9 * 10**7, MAX_TIMESTAMP // 2]:
            current_timestamp = web3.eth.getBlock("pending")["timestamp"]
            to_timestamp = current_timestamp + tΔ
            web3.manager.provider.ethereum_tester.time_travel(to_timestamp)
            web3.manager.provider.ethereum_tester.mine_block()
            t1 = web3.eth.getBlock("latest")["timestamp"]
>           assert t0 + tΔ <= t1 <= t0 + tΔ + ε
E           assert 12641211944 <= ((1579776492 + 3000000) + 10)

test/test_timetravel.py:36: AssertionError

How can it be fixed?

This works on Mac so perhaps there is an inconsistency with how it works on Ubuntu?

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

1 participant