ethereum/eth-tester

Time travel doesn't work on Ubuntu

Pet3ris opened this issue · 0 comments

  • 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?