def test_configure_invalid_vm_configuration(): with pytest.raises(ValidationError): EVM.configure(vm_configuration=[(-1, FrontierVM)]) with pytest.raises(ValidationError): EVM.configure(vm_configuration=[ (0, FrontierVM), (0, HomesteadVM), ] )
def test_get_vm_class_for_block_number(): evm_class = EVM.configure( vm_configuration=( (constants.GENESIS_BLOCK_NUMBER, FrontierVM), (constants.HOMESTEAD_MAINNET_BLOCK, HomesteadVM), ), ) evm = evm_class(MemoryDB(), BlockHeader(1, 0, 100)) assert evm.get_vm_class_for_block_number( constants.GENESIS_BLOCK_NUMBER,) == FrontierVM assert evm.get_vm_class_for_block_number( constants.HOMESTEAD_MAINNET_BLOCK - 1) == FrontierVM assert evm.get_vm_class_for_block_number( constants.HOMESTEAD_MAINNET_BLOCK) == HomesteadVM assert evm.get_vm_class_for_block_number( constants.HOMESTEAD_MAINNET_BLOCK + 1) == HomesteadVM
#from __future__ import print_function from binaryninja import PluginCommand from printSourceCode import function_source_code_start from coverage import function_coverage_start from evm import EVM, EVMView PluginCommand.register("EVM Source Code", "EVM Source Code Printer.", function_source_code_start) PluginCommand.register("EVM Manticore Highlight", "EVM Manticore Highlight", function_coverage_start) EVM.register() EVMView.register()
def test_get_vm_class_for_block_number_evm_not_found(): evm_class = EVM.configure(vm_configuration=()) evm = evm_class(MemoryDB(), BlockHeader(1, 0, 100)) with pytest.raises(EVMNotFound): evm.get_vm_class_for_block_number(constants.GENESIS_BLOCK_NUMBER)
from evm import constants from evm import EVM from evm.vm.flavors import ( FrontierVM, HomesteadVM, ) MainnetEVM = EVM.configure( 'MainnetEVM', vm_configuration=((0, FrontierVM), (constants.HOMESTEAD_MAINNET_BLOCK, HomesteadVM)))
return keccak("{0}".format(block_number)) FrontierVMForTesting = FrontierVM.configure( name='FrontierVMForTesting', get_block_hash=get_block_hash_for_testing, ) HomesteadVMForTesting = HomesteadVM.configure( name='HomesteadVMForTesting', get_block_hash=get_block_hash_for_testing, ) EVMForTesting = EVM.configure( name='EVMForTesting', vm_configuration=( (constants.GENESIS_BLOCK_NUMBER, FrontierVMForTesting), (constants.HOMESTEAD_MAINNET_BLOCK, HomesteadVMForTesting), ), ) def test_found_state_fixtures(): assert len(FIXTURES) != 0 @pytest.mark.parametrize( 'fixture_name,fixture', FIXTURES, ) def test_state_fixtures(fixture_name, fixture): header = BlockHeader(