コード例 #1
0
def test_london_configuration():
    if not is_supported_pyevm_version_available():
        pytest.skip("PyEVM is not available")

    backend = PyEVMBackend(vm_configuration=((0, LondonVM), ))

    assert backend.get_block_by_number(0)['base_fee_per_gas'] == 1000000000

    EthereumTester(backend=backend)
コード例 #2
0
def test_berlin_configuration():
    if not is_supported_pyevm_version_available():
        pytest.skip("PyEVM is not available")

    mnemonic = "test test test test test test test test test test test junk"
    vm_configuration = ((0, BerlinVM), )
    backend = PyEVMBackend.from_mnemonic(mnemonic,
                                         vm_configuration=vm_configuration)

    # Berlin blocks shouldn't have base_fee_per_gas,
    # since London was the fork that introduced base_fee_per_gas
    with pytest.raises(KeyError):
        backend.get_block_by_number(0)['base_fee_per_gas']

    EthereumTester(backend=backend)
コード例 #3
0
def test_berlin_configuration():
    if not is_supported_pyevm_version_available():
        pytest.skip("PyEVM is not available")

    mnemonic = "test test test test test test test test test test test junk"
    vm_configuration = ((0, BerlinVM), )
    backend = PyEVMBackend.from_mnemonic(mnemonic,
                                         vm_configuration=vm_configuration)

    # Berlin blocks shouldn't have base_fee_per_gas,
    # since London was the fork that introduced base_fee_per_gas
    with pytest.raises(KeyError):
        backend.get_block_by_number(0)['base_fee_per_gas']

    tester = EthereumTester(backend=backend)

    # Test that outbound block validation doesn't break by getting a block.
    berlin_block = tester.get_block_by_number(0)

    # Test that outbound block normalization removes `base_fee_per_gas`.
    with pytest.raises(KeyError):
        berlin_block['base_fee_per_gas']
コード例 #4
0
def test_custom_virtual_machines():
    if not is_supported_pyevm_version_available():
        pytest.skip("PyEVM is not available")

    backend = PyEVMBackend(vm_configuration=(
        (0, FrontierVM),
        (3, LondonVM),
    ))

    # This should be a FrontierVM block
    VM_at_2 = backend.chain.get_vm_class_for_block_number(2)
    # This should be a LondonVM block
    VM_at_3 = backend.chain.get_vm_class_for_block_number(3)

    assert issubclass(VM_at_2, FrontierVM)
    assert not issubclass(VM_at_2, LondonVM)
    assert issubclass(VM_at_3, LondonVM)

    # Right now, just test that EthereumTester doesn't crash
    # Maybe some more sophisticated test to make sure the VMs are set correctly?
    # We should to make sure the VM config translates all the way to the main
    #   tester, maybe with a custom VM that hard-codes some block value? that can
    #   be found with tester.get_block_by_number()?
    EthereumTester(backend=backend)
コード例 #5
0
def eth_tester():
    if not is_supported_pyevm_version_available():
        pytest.skip("PyEVM is not available")
    backend = PyEVMBackend()
    return EthereumTester(backend=backend)