diff --git a/test/vmtester/CMakeLists.txt b/test/vmtester/CMakeLists.txt index 52750ed..e17af70 100644 --- a/test/vmtester/CMakeLists.txt +++ b/test/vmtester/CMakeLists.txt @@ -7,7 +7,7 @@ include(GNUInstallDirs) add_executable(evmc-vmtester vmtester.hpp vmtester.cpp tests.cpp) set_target_properties(evmc-vmtester PROPERTIES RUNTIME_OUTPUT_DIRECTORY ..) -target_link_libraries(evmc-vmtester PRIVATE evmc loader evmc-example-host GTest::gtest) +target_link_libraries(evmc-vmtester PRIVATE evmc::loader evmc::mocked_host GTest::gtest) set_source_files_properties(vmtester.cpp PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION="${PROJECT_VERSION}") add_executable(evmc::evmc-vmtester ALIAS evmc-vmtester) diff --git a/test/vmtester/tests.cpp b/test/vmtester/tests.cpp index a16bc30..83ed52b 100644 --- a/test/vmtester/tests.cpp +++ b/test/vmtester/tests.cpp @@ -2,11 +2,9 @@ // Copyright 2018-2019 The EVMC Authors. // Licensed under the Apache License, Version 2.0. -#include "../../examples/example_host.h" #include "vmtester.hpp" - #include - +#include #include #include @@ -56,13 +54,13 @@ TEST_F(evmc_vm_test, capabilities) TEST_F(evmc_vm_test, execute_call) { - const evmc_host_interface* host = example_host_get_interface(); - evmc_host_context* context = example_host_create_context(evmc_tx_context{}); + evmc::MockedHost mockedHost; evmc_message msg{}; std::array code = {{0xfe, 0x00}}; evmc_result result = - vm->execute(vm, host, context, EVMC_MAX_REVISION, &msg, code.data(), code.size()); + vm->execute(vm, &evmc::MockedHost::get_interface(), mockedHost.to_context(), + EVMC_MAX_REVISION, &msg, code.data(), code.size()); // Validate some constraints if (result.status_code != EVMC_SUCCESS && result.status_code != EVMC_REVERT) @@ -84,21 +82,19 @@ TEST_F(evmc_vm_test, execute_call) if (result.release != nullptr) result.release(&result); - - example_host_destroy_context(context); } TEST_F(evmc_vm_test, execute_create) { - const evmc_host_interface* host = example_host_get_interface(); - evmc_host_context* context = example_host_create_context(evmc_tx_context{}); + evmc::MockedHost mockedHost; evmc_message msg{ EVMC_CREATE, 0, 0, 65536, evmc_address{}, evmc_address{}, nullptr, 0, evmc_uint256be{}, evmc_bytes32{}}; std::array code = {{0xfe, 0x00}}; evmc_result result = - vm->execute(vm, host, context, EVMC_MAX_REVISION, &msg, code.data(), code.size()); + vm->execute(vm, &evmc::MockedHost::get_interface(), mockedHost.to_context(), + EVMC_MAX_REVISION, &msg, code.data(), code.size()); // Validate some constraints if (result.status_code != EVMC_SUCCESS && result.status_code != EVMC_REVERT) @@ -121,8 +117,6 @@ TEST_F(evmc_vm_test, execute_create) if (result.release != nullptr) result.release(&result); - - example_host_destroy_context(context); } TEST_F(evmc_vm_test, set_option_unknown_name)