Skip to content

Commit

Permalink
tests: Verify deployed contract code in statetest runner
Browse files Browse the repository at this point in the history
  • Loading branch information
rodiazet committed Mar 23, 2023
1 parent 61ce7c6 commit 2f5f38a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/statetest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ target_sources(

add_executable(evmone-statetest)
target_link_libraries(evmone-statetest PRIVATE evmone::statetestutils evmone GTest::gtest)
target_include_directories(evmone-statetest PRIVATE ${evmone_private_include_dir})
target_sources(
evmone-statetest PRIVATE
statetest.cpp
Expand Down
9 changes: 9 additions & 0 deletions test/statetest/statetest_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "../state/mpt_hash.hpp"
#include "../state/rlp.hpp"
#include "statetest.hpp"
#include <evmone/eof.hpp>
#include <gtest/gtest.h>

namespace evmone::test
Expand All @@ -25,6 +26,14 @@ void run_state_test(const StateTransitionTest& test, evmc::VM& vm)
const auto tx = test.multi_tx.get(expected.indexes);
auto state = test.pre_state;

for (const auto& [add, acc] : state.get_accounts())
if (is_eof_container(acc.code))
if (const auto result = validate_eof(rev, acc.code);
result != EOFValidationError::success)
throw std::invalid_argument(
"deployed contract code validation failure: " + hex0x(add) + ": " +
get_error_message(result).data());

const auto res = state::transition(state, test.block, tx, rev, vm);
if (holds_alternative<state::TransactionReceipt>(res))
EXPECT_EQ(logs_hash(get<state::TransactionReceipt>(res).logs), expected.logs_hash);
Expand Down

0 comments on commit 2f5f38a

Please sign in to comment.