diff --git a/test/unittests/state_transition.cpp b/test/unittests/state_transition.cpp index a46cef4a21..c803b598fa 100644 --- a/test/unittests/state_transition.cpp +++ b/test/unittests/state_transition.cpp @@ -211,6 +211,20 @@ void state_transition::export_state_test( jtx["gasLimit"][0] = hex0x(tx.gas_limit); jtx["value"][0] = hex0x(tx.value); + if (!tx.access_list.empty()) + { + auto& ja = jtx["accessLists"][0]; + for (const auto& [addr, storage_keys] : tx.access_list) + { + json::json je; + je["address"] = hex0x(addr); + auto& jstorage_keys = je["storageKeys"] = json::json::array(); + for (const auto& k : storage_keys) + jstorage_keys.push_back(hex0x(k)); + ja.push_back(je); + } + } + auto& jpost = jt["post"][evmc::to_string(rev)][0]; jpost["indexes"] = {{"data", 0}, {"gas", 0}, {"value", 0}}; jpost["hash"] = hex0x(mpt_hash(post.get_accounts())); diff --git a/test/unittests/state_transition_tx_test.cpp b/test/unittests/state_transition_tx_test.cpp index c10b106263..c73d67b588 100644 --- a/test/unittests/state_transition_tx_test.cpp +++ b/test/unittests/state_transition_tx_test.cpp @@ -3,6 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "state_transition.hpp" +#include using namespace evmc::literals; using namespace evmone::test; @@ -93,3 +94,16 @@ TEST_F(state_transition, empty_coinbase_fee_0_tw) expect.post[To].exists = true; expect.post[Coinbase].balance = 0; } + +TEST_F(state_transition, access_list_storage) +{ + tx.to = To; + tx.access_list = {{To, {0x01_bytes32}}}; + + pre.insert(To, + {.storage = {{0x01_bytes32, {0x01_bytes32, 0x01_bytes32}}}, .code = sstore(2, sload(1))}); + + expect.post[To].storage[0x01_bytes32] = 0x01_bytes32; + expect.post[To].storage[0x02_bytes32] = 0x01_bytes32; + expect.gas_used = 47506; // Without access list: 45206 +}