|
| 1 | +// evmone: Fast Ethereum Virtual Machine implementation |
| 2 | +// Copyright 2023 The evmone Authors. |
| 3 | +// SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +#include <evmone/evmone.h> |
| 6 | +#include <gtest/gtest.h> |
| 7 | +#include <test/state/state.hpp> |
| 8 | +#include <test/utils/bytecode.hpp> |
| 9 | + |
| 10 | +using namespace evmc; |
| 11 | +using namespace evmone::state; |
| 12 | + |
| 13 | +TEST(state_system_call, non_existient) |
| 14 | +{ |
| 15 | + evmc::VM vm; |
| 16 | + State state; |
| 17 | + |
| 18 | + system_call(state, {}, EVMC_CANCUN, vm); |
| 19 | + |
| 20 | + EXPECT_EQ(state.get_accounts().size(), 0); |
| 21 | +} |
| 22 | + |
| 23 | +TEST(state_system_call, sstore_timestamp) |
| 24 | +{ |
| 25 | + static constexpr auto BeaconRootsAddress = 0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02_address; |
| 26 | + |
| 27 | + evmc::VM vm{evmc_create_evmone()}; |
| 28 | + const BlockInfo block{.number = 1, .timestamp = 404}; |
| 29 | + State state; |
| 30 | + state.insert(BeaconRootsAddress, {.code = sstore(OP_NUMBER, OP_TIMESTAMP)}); |
| 31 | + |
| 32 | + system_call(state, block, EVMC_CANCUN, vm); |
| 33 | + |
| 34 | + ASSERT_EQ(state.get_accounts().size(), 1); |
| 35 | + EXPECT_EQ(state.get(BeaconRootsAddress).nonce, 0); |
| 36 | + EXPECT_EQ(state.get(BeaconRootsAddress).balance, 0); |
| 37 | + const auto& storage = state.get(BeaconRootsAddress).storage; |
| 38 | + ASSERT_EQ(storage.size(), 1); |
| 39 | + EXPECT_EQ(storage.at(0x01_bytes32).current, 404); |
| 40 | +} |
0 commit comments