mirror of https://github.com/status-im/evmc.git
vmtester: Use MockedHost instead of ExampleHost
This commit is contained in:
parent
d43d827d88
commit
7f4d145090
|
@ -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)
|
||||
|
||||
|
|
|
@ -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 <evmc/evmc.hpp>
|
||||
|
||||
#include <evmc/mocked_host.hpp>
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
|
||||
|
@ -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<uint8_t, 2> 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<uint8_t, 2> 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)
|
||||
|
|
Loading…
Reference in New Issue