Skip to content

Commit 35b7475

Browse files
pdobaczchfast
andauthored
test: Ensure exported state tests have all fields (#993)
Co-authored-by: Paweł Bylica <[email protected]>
1 parent ad04d4e commit 35b7475

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

test/statetest/statetest_export.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace evmone::test
88
{
99
json::json to_json(const TestState& state)
1010
{
11-
json::json j;
11+
json::json j = json::json::object();
1212
for (const auto& [addr, acc] : state)
1313
{
1414
auto& j_acc = j[hex0x(addr)];

test/statetest/statetest_loader.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ template <>
273273
TestState from_json<TestState>(const json::json& j)
274274
{
275275
TestState o;
276+
assert(j.is_object());
276277
for (const auto& [j_addr, j_acc] : j.items())
277278
{
278279
auto& acc =

test/unittests/state_transition.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ void state_transition::export_state_test(
180180
jenv["currentGasLimit"] = hex0x(block.gas_limit);
181181
jenv["currentCoinbase"] = hex0x(block.coinbase);
182182
jenv["currentBaseFee"] = hex0x(block.base_fee);
183+
jenv["currentRandom"] = hex0x(block.prev_randao);
183184

184185
jt["pre"] = to_json(pre);
185186

@@ -204,6 +205,10 @@ void state_transition::export_state_test(
204205
jtx["gasLimit"][0] = hex0x(tx.gas_limit);
205206
jtx["value"][0] = hex0x(tx.value);
206207

208+
// Force `accessLists` output even if empty.
209+
if (tx.type >= Transaction::Type::access_list)
210+
jtx["accessLists"][0] = json::json::array();
211+
207212
if (!tx.access_list.empty())
208213
{
209214
auto& ja = jtx["accessLists"][0];

0 commit comments

Comments
 (0)