From 705b3379365a4bb104adbbf5a43ad29d82967bb5 Mon Sep 17 00:00:00 2001 From: pdobacz <5735525+pdobacz@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:54:06 +0200 Subject: [PATCH 1/4] Ensure state test have non-null pre --- test/statetest/statetest_export.cpp | 2 +- test/statetest/statetest_loader.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/statetest/statetest_export.cpp b/test/statetest/statetest_export.cpp index 7d2ed700ca..cb4c703dfc 100644 --- a/test/statetest/statetest_export.cpp +++ b/test/statetest/statetest_export.cpp @@ -8,7 +8,7 @@ namespace evmone::test { json::json to_json(const TestState& state) { - json::json j; + json::json j = json::json({}); for (const auto& [addr, acc] : state) { auto& j_acc = j[hex0x(addr)]; diff --git a/test/statetest/statetest_loader.cpp b/test/statetest/statetest_loader.cpp index fb77ae2467..7d24b34a64 100644 --- a/test/statetest/statetest_loader.cpp +++ b/test/statetest/statetest_loader.cpp @@ -273,6 +273,7 @@ template <> TestState from_json(const json::json& j) { TestState o; + assert(j.is_object()); for (const auto& [j_addr, j_acc] : j.items()) { auto& acc = From ad8a1c86d58b93d2fdad059f65785565c1891cb9 Mon Sep 17 00:00:00 2001 From: pdobacz <5735525+pdobacz@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:14:12 +0200 Subject: [PATCH 2/4] Review: use json::object() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Bylica --- test/statetest/statetest_export.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/statetest/statetest_export.cpp b/test/statetest/statetest_export.cpp index cb4c703dfc..d60b621f87 100644 --- a/test/statetest/statetest_export.cpp +++ b/test/statetest/statetest_export.cpp @@ -8,7 +8,7 @@ namespace evmone::test { json::json to_json(const TestState& state) { - json::json j = json::json({}); + json::json j = json::json::object(); for (const auto& [addr, acc] : state) { auto& j_acc = j[hex0x(addr)]; From 2d4d8e5eec1ece5e87914872cc61734081cbb20b Mon Sep 17 00:00:00 2001 From: pdobacz <5735525+pdobacz@users.noreply.github.com> Date: Tue, 10 Sep 2024 09:29:05 +0200 Subject: [PATCH 3/4] Ensure state test has accessLists and currentRandom --- test/unittests/state_transition.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/unittests/state_transition.cpp b/test/unittests/state_transition.cpp index 9a863ac25e..c46f75ca29 100644 --- a/test/unittests/state_transition.cpp +++ b/test/unittests/state_transition.cpp @@ -180,6 +180,7 @@ void state_transition::export_state_test( jenv["currentGasLimit"] = hex0x(block.gas_limit); jenv["currentCoinbase"] = hex0x(block.coinbase); jenv["currentBaseFee"] = hex0x(block.base_fee); + jenv["currentRandom"] = hex0x(block.prev_randao); jt["pre"] = to_json(pre); @@ -204,6 +205,9 @@ void state_transition::export_state_test( jtx["gasLimit"][0] = hex0x(tx.gas_limit); jtx["value"][0] = hex0x(tx.value); + if (tx.type >= Transaction::Type::access_list) + jtx["accessLists"][0] = json::json::array({}); + if (!tx.access_list.empty()) { auto& ja = jtx["accessLists"][0]; From 68da00b8bb44980a8557d09b580e0e7f3c26d401 Mon Sep 17 00:00:00 2001 From: pdobacz <5735525+pdobacz@users.noreply.github.com> Date: Tue, 10 Sep 2024 13:16:29 +0200 Subject: [PATCH 4/4] Update test/unittests/state_transition.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Bylica --- test/unittests/state_transition.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unittests/state_transition.cpp b/test/unittests/state_transition.cpp index c46f75ca29..804daa6d05 100644 --- a/test/unittests/state_transition.cpp +++ b/test/unittests/state_transition.cpp @@ -205,8 +205,9 @@ void state_transition::export_state_test( jtx["gasLimit"][0] = hex0x(tx.gas_limit); jtx["value"][0] = hex0x(tx.value); + // Force `accessLists` output even if empty. if (tx.type >= Transaction::Type::access_list) - jtx["accessLists"][0] = json::json::array({}); + jtx["accessLists"][0] = json::json::array(); if (!tx.access_list.empty()) {