diff --git a/test/statetest/statetest_loader.cpp b/test/statetest/statetest_loader.cpp index 9839d1b5e7..1e1688b6f1 100644 --- a/test/statetest/statetest_loader.cpp +++ b/test/statetest/statetest_loader.cpp @@ -182,6 +182,37 @@ evmc_revision to_rev(std::string_view s) throw std::invalid_argument{"unknown revision: " + std::string{s}}; } +template <> +state::Transaction from_json(const json::json& j) +{ + state::Transaction o; + o.data = from_json(j.at("input")); + o.gas_limit = from_json(j.at("gas")); + o.value = from_json(j.at("value")); + o.sender = from_json(j.at("sender")); + + if (!j.at("to").get().empty()) + o.to = from_json(j.at("to")); + + if (j.contains("gasPrice")) + { + o.kind = state::Transaction::Kind::legacy; + o.max_gas_price = from_json(j.at("gasPrice")); + o.max_priority_gas_price = o.max_gas_price; + } + else + { + o.kind = state::Transaction::Kind::eip1559; + o.max_gas_price = from_json(j.at("maxFeePerGas")); + o.max_priority_gas_price = from_json(j.at("maxPriorityFeePerGas")); + } + + if (j.contains("accessList")) + o.access_list = from_json(j.at("accessList")); + + return o; +} + static void from_json(const json::json& j, TestMultiTransaction& o) { if (j.contains("gasPrice")) @@ -255,37 +286,6 @@ static void from_json(const json::json& j, StateTransitionTest& o) } } -template <> -state::Transaction from_json(const json::json& j) -{ - state::Transaction o; - o.data = from_json(j.at("input")); - o.gas_limit = from_json(j.at("gas")); - o.value = from_json(j.at("value")); - o.sender = from_json(j.at("sender")); - - if (!j.at("to").get().empty()) - o.to = from_json(j.at("to")); - - if (j.contains("gasPrice")) - { - o.kind = state::Transaction::Kind::legacy; - o.max_gas_price = from_json(j.at("gasPrice")); - o.max_priority_gas_price = o.max_gas_price; - } - else - { - o.kind = state::Transaction::Kind::eip1559; - o.max_gas_price = from_json(j.at("maxFeePerGas")); - o.max_priority_gas_price = from_json(j.at("maxPriorityFeePerGas")); - } - - if (j.contains("accessList")) - o.access_list = from_json(j.at("accessList")); - - return o; -} - StateTransitionTest load_state_test(const fs::path& test_file) { return json::json::parse(std::ifstream{test_file}).get();