|
| 1 | +// evmone: Fast Ethereum Virtual Machine implementation |
| 2 | +// Copyright 2023 The evmone Authors. |
| 3 | +// SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +#include "../utils/bytecode.hpp" |
| 6 | +#include "state_transition.hpp" |
| 7 | + |
| 8 | +using namespace evmc::literals; |
| 9 | +using namespace evmone::test; |
| 10 | + |
| 11 | +TEST_F(state_transition, selfdestruct_shanghai) |
| 12 | +{ |
| 13 | + rev = EVMC_SHANGHAI; |
| 14 | + tx.to = To; |
| 15 | + pre.insert(*tx.to, {.balance = 0x4e, .code = selfdestruct(0xbe_address)}); |
| 16 | + |
| 17 | + expect.post[To].exists = false; |
| 18 | + expect.post[0xbe_address].balance = 0x4e; |
| 19 | +} |
| 20 | + |
| 21 | +TEST_F(state_transition, selfdestruct_cancun) |
| 22 | +{ |
| 23 | + rev = EVMC_CANCUN; |
| 24 | + tx.to = To; |
| 25 | + pre.insert(*tx.to, {.balance = 0x4e, .code = selfdestruct(0xbe_address)}); |
| 26 | + |
| 27 | + expect.post[To].balance = 0; |
| 28 | + expect.post[0xbe_address].balance = 0x4e; |
| 29 | +} |
| 30 | + |
| 31 | +TEST_F(state_transition, selfdestruct_to_self_cancun) |
| 32 | +{ |
| 33 | + rev = EVMC_CANCUN; |
| 34 | + tx.to = To; |
| 35 | + pre.insert(*tx.to, {.balance = 0x4e, .code = selfdestruct(To)}); |
| 36 | + |
| 37 | + expect.post[To].balance = 0x4e; |
| 38 | +} |
| 39 | + |
| 40 | +TEST_F(state_transition, selfdestruct_same_tx_cancun) |
| 41 | +{ |
| 42 | + rev = EVMC_CANCUN; |
| 43 | + tx.value = 0x4e; |
| 44 | + tx.data = selfdestruct(0xbe_address); |
| 45 | + pre.get(Sender).balance += 0x4e; |
| 46 | + |
| 47 | + expect.post[0xbe_address].balance = 0x4e; |
| 48 | +} |
0 commit comments