Skip to content

Commit

Permalink
test: Ensure exported state tests have all fields (#993)
Browse files Browse the repository at this point in the history
Co-authored-by: Paweł Bylica <pawel@ethereum.org>
  • Loading branch information
pdobacz and chfast authored Sep 11, 2024
1 parent ad04d4e commit 35b7475
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/statetest/statetest_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace evmone::test
{
json::json to_json(const TestState& state)
{
json::json j;
json::json j = json::json::object();
for (const auto& [addr, acc] : state)
{
auto& j_acc = j[hex0x(addr)];
Expand Down
1 change: 1 addition & 0 deletions test/statetest/statetest_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ template <>
TestState from_json<TestState>(const json::json& j)
{
TestState o;
assert(j.is_object());
for (const auto& [j_addr, j_acc] : j.items())
{
auto& acc =
Expand Down
5 changes: 5 additions & 0 deletions test/unittests/state_transition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -204,6 +205,10 @@ 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();

if (!tx.access_list.empty())
{
auto& ja = jtx["accessLists"][0];
Expand Down

0 comments on commit 35b7475

Please sign in to comment.