diff --git a/test/blockchaintest/blockchaintest.cpp b/test/blockchaintest/blockchaintest.cpp index e34fe3d61e..e3de6ab4de 100644 --- a/test/blockchaintest/blockchaintest.cpp +++ b/test/blockchaintest/blockchaintest.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "blockchaintest.hpp" +#include "../statetest/statetest.hpp" #include #include #include diff --git a/test/blockchaintest/blockchaintest.hpp b/test/blockchaintest/blockchaintest.hpp index 0b1e4cc84a..318d1d2df3 100644 --- a/test/blockchaintest/blockchaintest.hpp +++ b/test/blockchaintest/blockchaintest.hpp @@ -14,11 +14,6 @@ namespace evmone::test { -struct UnsupportedTestFeature : std::runtime_error -{ - using runtime_error::runtime_error; -}; - // https://ethereum.org/en/developers/docs/blocks/ struct BlockHeader { diff --git a/test/statetest/statetest.cpp b/test/statetest/statetest.cpp index 8a78a25964..f5b3f42815 100644 --- a/test/statetest/statetest.cpp +++ b/test/statetest/statetest.cpp @@ -27,9 +27,16 @@ class StateTest : public testing::Test void TestBody() final { std::ifstream f{m_json_test_file}; - const auto tests = evmone::test::load_state_tests(f); - for (const auto& test : tests) - evmone::test::run_state_test(test, m_vm, m_trace); + try + { + const auto tests = evmone::test::load_state_tests(f); + for (const auto& test : tests) + evmone::test::run_state_test(test, m_vm, m_trace); + } + catch (const evmone::test::UnsupportedTestFeature& ex) + { + GTEST_SKIP() << ex.what(); + } } }; diff --git a/test/statetest/statetest.hpp b/test/statetest/statetest.hpp index b2112c13c3..3f0453bf44 100644 --- a/test/statetest/statetest.hpp +++ b/test/statetest/statetest.hpp @@ -13,6 +13,10 @@ namespace json = nlohmann; namespace evmone::test { +struct UnsupportedTestFeature : std::runtime_error +{ + using runtime_error::runtime_error; +}; struct TestMultiTransaction : state::Transaction { diff --git a/test/statetest/statetest_loader.cpp b/test/statetest/statetest_loader.cpp index a1170e2934..2c4a5c2f92 100644 --- a/test/statetest/statetest_loader.cpp +++ b/test/statetest/statetest_loader.cpp @@ -128,13 +128,34 @@ state::AuthorizationList from_json(const json::json& j for (const auto& a : j) { state::Authorization authorization{}; - authorization.chain_id = from_json(a.at("chainId")); + try + { + authorization.chain_id = from_json(a.at("chainId")); + } + catch (const std::out_of_range&) + { + throw UnsupportedTestFeature("tests with out of range chainId are not supported"); + } authorization.addr = from_json
(a.at("address")); - authorization.nonce = from_json(a.at("nonce")); + try + { + authorization.nonce = from_json(a.at("nonce")); + } + catch (const std::out_of_range&) + { + throw UnsupportedTestFeature("tests with out of range nonce are not supported"); + } if (a.contains("signer")) authorization.signer = from_json
(a.at("signer")); - authorization.r = from_json(a.at("r")); - authorization.s = from_json(a.at("s")); + try + { + authorization.r = from_json(a.at("r")); + authorization.s = from_json(a.at("s")); + } + catch (const std::out_of_range&) + { + throw UnsupportedTestFeature("tests with out of range r and s are not supported"); + } authorization.v = from_json(a.at("v")); o.emplace_back(authorization); }