From 451a0fe3efa473a2c3746f0cf067709d05b97b31 Mon Sep 17 00:00:00 2001 From: Marcos Pernambuco Motta <1091485+mpernambuco@users.noreply.github.com> Date: Sat, 3 Aug 2024 21:10:42 -0300 Subject: [PATCH] feat: change layout of uarch json logs --- tests/lua/uarch-riscv-tests.lua | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tests/lua/uarch-riscv-tests.lua b/tests/lua/uarch-riscv-tests.lua index d2ef4fd6f..503638047 100755 --- a/tests/lua/uarch-riscv-tests.lua +++ b/tests/lua/uarch-riscv-tests.lua @@ -389,19 +389,18 @@ local function write_access_to_log(access, out, indent, last) util.indentout(out, indent + 1, '"type": "%s",\n', access.type) util.indentout(out, indent + 1, '"address": %u,\n', access.address) util.indentout(out, indent + 1, '"log2_size": %u,\n', access.log2_size) + local read_value = '""' -- Solidity JSON parser breaks, if this field is null + if access.read then read_value = '"' .. util.hexstring(access.read) .. '"' end + util.indentout(out, indent + 1, '"read_value": %s,\n', read_value) + util.indentout(out, indent + 1, '"read_hash": "%s",\n', util.hexhash(access.read_hash)) + local written = '' + local written_hash = '' if access.type == "write" then - local value = "null" - if access.written then value = '"' .. util.hexstring(access.written) .. '"' end - util.indentout(out, indent + 1, '"value": %s,', value) - util.indentout(out, indent + 1, '"hash": "%s",', util.hexhash(access.written_hash)) - util.indentout(out, indent + 1, '"read_hash": "%s"', util.hexhash(access.read_hash)) - else - local value = "null" - if access.read then value = '"' .. util.hexstring(access.read) .. '"' end - util.indentout(out, indent + 1, '"value": %s,', value) - util.indentout(out, indent + 1, '"hash": "%s",', util.hexhash(access.read_hash)) - util.indentout(out, indent + 1, '"read_hash": "%s"', util.hexhash(access.read_hash)) + written_hash = util.hexhash(access.written_hash) + if access.written then written = util.hexstring(access.written) end end + util.indentout(out, indent + 1, '"written": "%s",\n', written) + util.indentout(out, indent + 1, '"written_hash": "%s"', written_hash) if access.sibling_hashes then out:write(",\n") write_sibling_hashes_to_log(access.sibling_hashes, out, indent + 2)