From be80c7dcf7998e93a55b7cefe3b11015d5431ebe Mon Sep 17 00:00:00 2001 From: rodiazet Date: Tue, 21 Mar 2023 12:14:27 +0100 Subject: [PATCH] statetest: Allow special "0" value for JSON bytearray --- test/statetest/statetest_loader.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/statetest/statetest_loader.cpp b/test/statetest/statetest_loader.cpp index 46d3f77681..932069e42f 100644 --- a/test/statetest/statetest_loader.cpp +++ b/test/statetest/statetest_loader.cpp @@ -148,7 +148,14 @@ state::BlockInfo from_json(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(*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() == "0") + difficulty = 0x0000000000000000000000000000000000000000000000000000000000000000_bytes32; + else + difficulty = from_json(*prev_randao_it); + } else if (current_difficulty_it != j.end()) difficulty = from_json(*current_difficulty_it); else if (parent_difficulty_it != j.end())