def test_from_mnemonic(self): # Initialize PyEVM backend using MNEMONIC, num_accounts, # and state overrides (balance) num_accounts = 3 balance = to_wei(15, "ether") # Give each account 15 Eth pyevm_backend = PyEVMBackend.from_mnemonic( MNEMONIC, num_accounts=num_accounts, genesis_state_overrides={"balance": balance}) # Each of these accounts stems from the MNEMONIC expected_accounts = [ "0x1e59ce931b4cfea3fe4b875411e280e173cb7a9c", "0xc89d42189f0450c2b2c3c61f58ec5d628176a1e7", "0x318b469bba396aec2c60342f9441be36a1945174" ] # Test integration with EthereumTester tester = EthereumTester(backend=pyevm_backend) actual_accounts = tester.get_accounts() assert len(actual_accounts) == num_accounts for i in range(0, num_accounts): actual = actual_accounts[i] expected = expected_accounts[i] assert actual.lower() == expected.lower() assert tester.get_balance(account=actual) == balance
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)
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']