Skip to content

Commit

Permalink
statetest: Allow special "0" value for JSON bytearray
Browse files Browse the repository at this point in the history
  • Loading branch information
rodiazet authored and chfast committed Mar 27, 2023
1 parent a93e69b commit be80c7d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/statetest/statetest_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,14 @@ state::BlockInfo from_json<state::BlockInfo>(const json::json& j)
const auto current_difficulty_it = j.find("currentDifficulty");
const auto parent_difficulty_it = j.find("parentDifficulty");
if (prev_randao_it != j.end())
difficulty = from_json<evmc::bytes32>(*prev_randao_it);
{
// Special case to handle "0". Required by exec-spec-tests.
// TODO: Get rid of it.
if (prev_randao_it->is_string() && prev_randao_it->get<std::string>() == "0")
difficulty = 0x0000000000000000000000000000000000000000000000000000000000000000_bytes32;
else
difficulty = from_json<evmc::bytes32>(*prev_randao_it);
}
else if (current_difficulty_it != j.end())
difficulty = from_json<evmc::bytes32>(*current_difficulty_it);
else if (parent_difficulty_it != j.end())
Expand Down

0 comments on commit be80c7d

Please sign in to comment.