Skip to content

Commit

Permalink
Use MockedHost from EVMC
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Nov 29, 2019
1 parent eb88018 commit 2010180
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 260 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ endif()
hunter_add_package(ethash)
find_package(ethash CONFIG REQUIRED)

option(EVMC_TEST_TOOLS "Build EVMC test tools" ${EVMONE_TESTING})
option(EVMC_TOOLS "Build EVMC test tools" ${EVMONE_TESTING})
add_subdirectory(evmc)

cable_configure_compiler()
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Licensed under the Apache License, Version 2.0.

include(GoogleTest)
include(${PROJECT_SOURCE_DIR}/evmc/cmake/EVMC.cmake)

set(evmone_private_include_dir ${PROJECT_SOURCE_DIR}/lib)

Expand Down
2 changes: 1 addition & 1 deletion test/fuzzer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ else()
endif()

add_executable(evmone-fuzzer fuzzer.cpp)
target_link_libraries(evmone-fuzzer PRIVATE evmone testutils)
target_link_libraries(evmone-fuzzer PRIVATE evmone testutils evmc::mocked_host)

if(NOT fuzzing_coverage)
# TODO: Aleth reports undefined behaviors, disable it for fuzzing.
Expand Down
5 changes: 3 additions & 2 deletions test/fuzzer/fuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// Copyright 2019 The evmone Authors.
// Licensed under the Apache License, Version 2.0.

#include <evmc/mocked_host.hpp>
#include <evmone/evmone.h>
#include <test/utils/bytecode.hpp>
#include <test/utils/host_mock.hpp>
#include <test/utils/utils.hpp>

#include <cstring>
#include <iostream>

Expand Down Expand Up @@ -68,7 +69,7 @@ static evmc::VM external_vms[] = {
};


class FuzzHost : public MockedHost
class FuzzHost : public evmc::MockedHost
{
public:
uint8_t gas_left_factor = 0;
Expand Down
2 changes: 1 addition & 1 deletion test/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ add_library(evm-unittests OBJECT
evm_state_test.cpp
evm_other_test.cpp
)
target_link_libraries(evm-unittests PRIVATE testutils evmc::evmc GTest::gtest)
target_link_libraries(evm-unittests PRIVATE testutils evmc::mocked_host GTest::gtest)
target_include_directories(evm-unittests PRIVATE ${evmone_private_include_dir})

# The internal evmone unit tests. The generic EVM ones are also built in.
Expand Down
5 changes: 3 additions & 2 deletions test/unittests/evm_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#pragma once

#include "vm_loader.hpp"

#include <evmc/mocked_host.hpp>
#include <gtest/gtest.h>
#include <intx/intx.hpp>
#include <test/utils/bytecode.hpp>
#include <test/utils/host_mock.hpp>

#define EXPECT_STATUS(STATUS_CODE) \
EXPECT_EQ(result.status_code, STATUS_CODE); \
Expand Down Expand Up @@ -56,7 +57,7 @@ class evm : public testing::Test
/// The total amount of gas used during execution.
int64_t gas_used = 0;

MockedHost host;
evmc::MockedHost host;

evm() noexcept : vm{get_vm()} {}

Expand Down
2 changes: 1 addition & 1 deletion test/unittests/evm_state_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ TEST_F(evm_state, selfdestruct_with_balance)

TEST_F(evm_state, blockhash)
{
host.blockhash.bytes[13] = 0x13;
host.block_hash.bytes[13] = 0x13;

host.tx_context.block_number = 0;
auto code = "60004060005260206000f3";
Expand Down
1 change: 0 additions & 1 deletion test/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ find_package(intx CONFIG REQUIRED)

add_library(testutils STATIC
bytecode.hpp
host_mock.hpp
utils.cpp
utils.hpp
)
Expand Down
251 changes: 0 additions & 251 deletions test/utils/host_mock.hpp

This file was deleted.

0 comments on commit 2010180

Please sign in to comment.