|
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,96 @@ 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 | + initcode=expensively_reverting_container, |
| 104 | + initcode_execution_cost=expensively_reverting_container_gas, |
| 105 | + runtime=None, |
| 106 | + ), |
| 107 | + id="expensively_reverting_initcode", |
| 108 | + ), |
| 109 | + pytest.param( |
| 110 | + dict( |
| 111 | + initcode=Container.Init(big_runtime_subcontainer), |
| 112 | + runtime=big_runtime_subcontainer, |
| 113 | + ), |
| 114 | + id="big_runtime", |
| 115 | + ), |
| 116 | + pytest.param( |
| 117 | + dict( |
| 118 | + initcode=Container.Init(make_factory(smallest_initcode_subcontainer)), |
| 119 | + runtime=make_factory(smallest_initcode_subcontainer), |
| 120 | + ), |
| 121 | + id="nested_initcode", |
| 122 | + ), |
| 123 | + pytest.param( |
| 124 | + dict( |
| 125 | + initcode=bigger_initcode_subcontainer, |
| 126 | + initcode_execution_cost=bigger_initcode_subcontainer_gas, |
| 127 | + ), |
| 128 | + id="bigger_initcode", |
| 129 | + ), |
| 130 | + pytest.param( |
| 131 | + dict( |
| 132 | + initcode=data_initcode_subcontainer, |
| 133 | + runtime=data_runtime_container, |
| 134 | + ), |
| 135 | + id="data_initcode", |
| 136 | + ), |
| 137 | + pytest.param( |
| 138 | + dict( |
| 139 | + initcode=data_appending_initcode_subcontainer, |
| 140 | + initcode_execution_cost=data_appending_initcode_subcontainer_gas, |
| 141 | + runtime=data_runtime_container, |
| 142 | + ), |
| 143 | + id="data_appending_initcode", |
| 144 | + ), |
| 145 | + ], |
| 146 | + ) |
114 | 147 | )
|
115 | 148 | def test_eofcreate_gas(
|
116 | 149 | state_test: StateTestFiller,
|
|
0 commit comments