Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Ensure exported state tests have all fields #993

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
pdobacz marked this conversation as resolved.
Show resolved Hide resolved
jtx["accessLists"][0] = json::json::array();

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