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 264e395 commit ac7cb1b
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 261 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
2 changes: 1 addition & 1 deletion evmc
Submodule evmc updated 42 files
+1 −1 .bumpversion.cfg
+44 −0 .clang-tidy
+24 −0 CHANGELOG.md
+21 −21 CMakeLists.txt
+1 −1 README.md
+1 −1 bindings/rust/evmc-declare-tests/Cargo.toml
+4 −8 bindings/rust/evmc-declare/Cargo.toml
+5 −6 bindings/rust/evmc-declare/src/lib.rs
+2 −2 bindings/rust/evmc-sys/Cargo.toml
+1 −1 bindings/rust/evmc-vm/Cargo.toml
+49 −53 bindings/rust/evmc-vm/src/lib.rs
+64 −0 bindings/rust/evmc-vm/src/types.rs
+10 −3 circle.yml
+3 −9 examples/CMakeLists.txt
+2 −2 examples/example-rust-vm/src/lib.rs
+17 −12 examples/example_host.cpp
+2 −2 examples/example_precompiles_vm/CMakeLists.txt
+5 −21 examples/example_precompiles_vm/example_precompiles_vm.cpp
+2 −2 examples/example_vm/CMakeLists.txt
+1 −1 include/evmc/evmc.h
+25 −19 include/evmc/evmc.hpp
+315 −0 include/evmc/mocked_host.hpp
+14 −0 lib/CMakeLists.txt
+8 −3 lib/instructions/CMakeLists.txt
+1 −4 lib/loader/CMakeLists.txt
+6 −0 lib/loader/loader.c
+13 −0 lib/mocked_host/CMakeLists.txt
+3 −17 test/CMakeLists.txt
+0 −0 test/cmake_package/CMakeLists.txt
+0 −0 test/compilation/CMakeLists.txt
+0 −0 test/compilation/compilation_test.c
+2 −0 test/compilation/compilation_test.cxx
+0 −6 test/integration/CMakeLists.txt
+8 −3 test/unittests/CMakeLists.txt
+78 −31 test/unittests/test_cpp.cpp
+39 −5 test/unittests/test_loader.cpp
+7 −19 test/vmtester/CMakeLists.txt
+5 −0 tools/CMakeLists.txt
+21 −0 tools/vmtester/CMakeLists.txt
+14 −23 tools/vmtester/tests.cpp
+1 −1 tools/vmtester/vmtester.cpp
+0 −0 tools/vmtester/vmtester.hpp
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 ac7cb1b

Please sign in to comment.