|
6 | 6 |
|
7 | 7 | from ethereum_test_tools import Alloc, Environment, StateTestFiller, compute_eofcreate_address |
8 | 8 | from ethereum_test_tools.eof.v1 import Container, Section |
| 9 | +from ethereum_test_tools.utility.pytest import extend_with_defaults |
9 | 10 | from ethereum_test_tools.vm.opcode import Opcodes as Op |
10 | 11 | from ethereum_test_types.helpers import cost_memory_bytes |
11 | 12 |
|
@@ -53,64 +54,113 @@ def make_factory(initcode: Container): |
53 | 54 | @pytest.mark.parametrize("value", [0, 1]) |
54 | 55 | @pytest.mark.parametrize("new_account", [True, False]) |
55 | 56 | @pytest.mark.parametrize( |
56 | | - "mem_expansion_bytes", |
57 | | - [0, 1, 32, 33], |
58 | | -) |
59 | | -@pytest.mark.parametrize( |
60 | | - ["initcode", "initcode_execution_cost", "runtime"], |
61 | | - [ |
62 | | - pytest.param( |
63 | | - smallest_initcode_subcontainer, |
64 | | - smallest_initcode_subcontainer_gas, |
65 | | - smallest_runtime_subcontainer, |
66 | | - id="smallest_code", |
67 | | - ), |
68 | | - pytest.param( |
69 | | - Container.Init(aborting_container), |
70 | | - smallest_initcode_subcontainer_gas, |
71 | | - aborting_container, |
72 | | - id="aborting_runtime", |
73 | | - ), |
74 | | - pytest.param( |
75 | | - reverting_container, smallest_initcode_subcontainer_gas, None, id="reverting_initcode" |
76 | | - ), |
77 | | - pytest.param( |
78 | | - expensively_reverting_container, |
79 | | - expensively_reverting_container_gas, |
80 | | - None, |
81 | | - id="expensively_reverting_initcode", |
82 | | - ), |
83 | | - pytest.param( |
84 | | - Container.Init(big_runtime_subcontainer), |
85 | | - smallest_initcode_subcontainer_gas, |
86 | | - big_runtime_subcontainer, |
87 | | - id="big_runtime", |
| 57 | + **extend_with_defaults( |
| 58 | + defaults=dict( |
| 59 | + mem_expansion_bytes=0, |
| 60 | + initcode=smallest_initcode_subcontainer, |
| 61 | + initcode_execution_cost=smallest_initcode_subcontainer_gas, |
| 62 | + runtime=smallest_runtime_subcontainer, |
88 | 63 | ), |
89 | | - pytest.param( |
90 | | - Container.Init(make_factory(smallest_initcode_subcontainer)), |
91 | | - smallest_initcode_subcontainer_gas, |
92 | | - make_factory(smallest_initcode_subcontainer), |
93 | | - id="nested_initcode", |
94 | | - ), |
95 | | - pytest.param( |
96 | | - bigger_initcode_subcontainer, |
97 | | - bigger_initcode_subcontainer_gas, |
98 | | - smallest_runtime_subcontainer, |
99 | | - id="bigger_initcode", |
100 | | - ), |
101 | | - pytest.param( |
102 | | - data_initcode_subcontainer, |
103 | | - smallest_initcode_subcontainer_gas, |
104 | | - data_runtime_container, |
105 | | - id="data_initcode", |
106 | | - ), |
107 | | - pytest.param( |
108 | | - data_appending_initcode_subcontainer, |
109 | | - data_appending_initcode_subcontainer_gas, |
110 | | - data_runtime_container, |
111 | | - id="data_appending_initcode", |
112 | | - ), |
113 | | - ], |
| 64 | + cases=[ |
| 65 | + pytest.param( |
| 66 | + dict(), |
| 67 | + id="smallest_code", |
| 68 | + ), |
| 69 | + pytest.param( |
| 70 | + dict( |
| 71 | + mem_expansion_bytes=1, |
| 72 | + ), |
| 73 | + id="mem_expansion_1byte", |
| 74 | + ), |
| 75 | + pytest.param( |
| 76 | + dict( |
| 77 | + mem_expansion_bytes=32, |
| 78 | + ), |
| 79 | + id="mem_expansion_1word", |
| 80 | + ), |
| 81 | + pytest.param( |
| 82 | + dict( |
| 83 | + mem_expansion_bytes=33, |
| 84 | + ), |
| 85 | + id="mem_expansion_2words", |
| 86 | + ), |
| 87 | + pytest.param( |
| 88 | + dict( |
| 89 | + initcode=Container.Init(aborting_container), |
| 90 | + runtime=aborting_container, |
| 91 | + ), |
| 92 | + id="aborting_runtime", |
| 93 | + ), |
| 94 | + pytest.param( |
| 95 | + dict( |
| 96 | + initcode=reverting_container, |
| 97 | + runtime=None, |
| 98 | + ), |
| 99 | + id="reverting_initcode", |
| 100 | + ), |
| 101 | + pytest.param( |
| 102 | + dict( |
| 103 | + mem_expansion_bytes=1, |
| 104 | + initcode=reverting_container, |
| 105 | + runtime=None, |
| 106 | + ), |
| 107 | + id="reverting_initcode_mem_expansion_1byte", |
| 108 | + ), |
| 109 | + pytest.param( |
| 110 | + dict( |
| 111 | + initcode=expensively_reverting_container, |
| 112 | + initcode_execution_cost=expensively_reverting_container_gas, |
| 113 | + runtime=None, |
| 114 | + ), |
| 115 | + id="expensively_reverting_initcode", |
| 116 | + ), |
| 117 | + pytest.param( |
| 118 | + dict( |
| 119 | + initcode=Container.Init(big_runtime_subcontainer), |
| 120 | + runtime=big_runtime_subcontainer, |
| 121 | + ), |
| 122 | + id="big_runtime", |
| 123 | + ), |
| 124 | + pytest.param( |
| 125 | + dict( |
| 126 | + initcode=Container.Init(make_factory(smallest_initcode_subcontainer)), |
| 127 | + runtime=make_factory(smallest_initcode_subcontainer), |
| 128 | + ), |
| 129 | + id="nested_initcode", |
| 130 | + ), |
| 131 | + pytest.param( |
| 132 | + dict( |
| 133 | + initcode=bigger_initcode_subcontainer, |
| 134 | + initcode_execution_cost=bigger_initcode_subcontainer_gas, |
| 135 | + ), |
| 136 | + id="bigger_initcode", |
| 137 | + ), |
| 138 | + pytest.param( |
| 139 | + dict( |
| 140 | + initcode=data_initcode_subcontainer, |
| 141 | + runtime=data_runtime_container, |
| 142 | + ), |
| 143 | + id="data_initcode", |
| 144 | + ), |
| 145 | + pytest.param( |
| 146 | + dict( |
| 147 | + initcode=data_appending_initcode_subcontainer, |
| 148 | + initcode_execution_cost=data_appending_initcode_subcontainer_gas, |
| 149 | + runtime=data_runtime_container, |
| 150 | + ), |
| 151 | + id="data_appending_initcode", |
| 152 | + ), |
| 153 | + pytest.param( |
| 154 | + dict( |
| 155 | + mem_expansion_bytes=1, |
| 156 | + initcode=data_appending_initcode_subcontainer, |
| 157 | + initcode_execution_cost=data_appending_initcode_subcontainer_gas, |
| 158 | + runtime=data_runtime_container, |
| 159 | + ), |
| 160 | + id="data_appending_initcode_mem_expansion_1byte", |
| 161 | + ), |
| 162 | + ], |
| 163 | + ) |
114 | 164 | ) |
115 | 165 | def test_eofcreate_gas( |
116 | 166 | state_test: StateTestFiller, |
|
0 commit comments