33after being called for self destruct in a call.
44"""
55
6- from enum import Enum
6+ from enum import IntEnum
77
88import pytest
99
1010from ethereum_test_forks import Byzantium , Fork
1111from ethereum_test_tools import (
1212 Account ,
1313 Alloc ,
14- Case ,
15- Environment ,
14+ CalldataCase ,
1615 Initcode ,
1716 StateTestFiller ,
1817 Storage ,
2322from ethereum_test_tools import Opcodes as Op
2423
2524
26- class Operation (Enum ):
25+ class Operation (IntEnum ):
2726 """Enum for created contract actions."""
2827
2928 SUICIDE = 1
3029 ADD_STORAGE = 2
3130 GET_STORAGE = 3
3231
33- def __int__ (self ):
34- """Convert to int."""
35- return int (self .value )
36-
3732
3833@pytest .mark .ported_from (
3934 [
@@ -50,7 +45,7 @@ def test_create_suicide_store(
5045 fork : Fork ,
5146 pre : Alloc ,
5247 create_opcode : Op ,
53- ):
48+ ) -> None :
5449 """
5550 Create dynamic contract that suicides, then called to push some storage
5651 and then called to return that storage value.
@@ -60,21 +55,21 @@ def test_create_suicide_store(
6055 suicide_initcode : Initcode = Initcode (
6156 deploy_code = Switch (
6257 cases = [
63- Case (
64- condition = Op . EQ ( Op . CALLDATALOAD ( 0 ), int ( Operation .SUICIDE )) ,
65- action = Op .SELFDESTRUCT (0x11 ),
58+ CalldataCase (
59+ value = Operation .SUICIDE ,
60+ action = Op .SELFDESTRUCT (pre . empty_account () ),
6661 ),
67- Case (
68- condition = Op . EQ ( Op . CALLDATALOAD ( 0 ), int ( Operation .ADD_STORAGE )) ,
62+ CalldataCase (
63+ value = Operation .ADD_STORAGE ,
6964 action = Op .SSTORE (1 , Op .ADD (Op .SLOAD (1 ), subcall_storage ))
7065 + (
7166 Op .TSTORE (1 , Op .ADD (Op .TLOAD (1 ), subcall_storage ))
7267 if tload_support
7368 else Op .STOP
7469 ),
7570 ),
76- Case (
77- condition = Op . EQ ( Op . CALLDATALOAD ( 0 ), int ( Operation .GET_STORAGE )) ,
71+ CalldataCase (
72+ value = Operation .GET_STORAGE ,
7873 action = (
7974 Op .MSTORE (0 , Op .ADD (Op .SLOAD (1 ), Op .TLOAD (1 )))
8075 if tload_support
@@ -94,32 +89,32 @@ def test_create_suicide_store(
9489 slot_after_suicide_sstore_return = 1
9590 slot_program_success = 2
9691 create_contract = pre .deploy_contract (
97- code = Op .CALLDATACOPY (0 , 0 , Op .CALLDATASIZE )
92+ code = Op .CALLDATACOPY (size = Op .CALLDATASIZE () )
9893 + Op .SSTORE (slot_create_result , create_opcode (size = Op .CALLDATASIZE ()))
9994 # Put some storage before suicide
100- + Op .MSTORE (64 , int ( Operation .ADD_STORAGE ) )
95+ + Op .MSTORE (64 , Operation .ADD_STORAGE )
10196 + Op .CALL (
10297 gas = Op .SUB (Op .GAS , 300_000 ),
10398 address = Op .SLOAD (slot_create_result ),
10499 args_offset = 64 ,
105100 args_size = 32 ,
106101 )
107- + Op .MSTORE (64 , int ( Operation .SUICIDE ) )
102+ + Op .MSTORE (64 , Operation .SUICIDE )
108103 + Op .CALL (
109104 gas = Op .SUB (Op .GAS , 300_000 ),
110105 address = Op .SLOAD (slot_create_result ),
111106 args_offset = 64 ,
112107 args_size = 32 ,
113108 )
114109 # Put some storage after suicide
115- + Op .MSTORE (64 , int ( Operation .ADD_STORAGE ) )
110+ + Op .MSTORE (64 , Operation .ADD_STORAGE )
116111 + Op .CALL (
117112 gas = Op .SUB (Op .GAS , 300_000 ),
118113 address = Op .SLOAD (slot_create_result ),
119114 args_offset = 64 ,
120115 args_size = 32 ,
121116 )
122- + Op .MSTORE (64 , int ( Operation .GET_STORAGE ) )
117+ + Op .MSTORE (64 , Operation .GET_STORAGE )
123118 + Op .CALL (
124119 gas = Op .SUB (Op .GAS , 300_000 ),
125120 address = Op .SLOAD (0 ),
@@ -146,7 +141,6 @@ def test_create_suicide_store(
146141 gas_limit = 1_000_000 ,
147142 to = create_contract ,
148143 data = suicide_initcode ,
149- nonce = 0 ,
150144 sender = sender ,
151145 protected = fork >= Byzantium ,
152146 )
@@ -155,4 +149,4 @@ def test_create_suicide_store(
155149 create_contract : Account (storage = expect_post ),
156150 expected_create_address : Account .NONEXISTENT ,
157151 }
158- state_test (env = Environment (), pre = pre , post = post , tx = tx )
152+ state_test (pre = pre , post = post , tx = tx )
0 commit comments