Skip to content

Commit 6636828

Browse files
authored
Merge pull request #69 from spencer-tb/name-every-fixtures
Fixture Format: Add descriptive name to every fixture test.
2 parents ca781a5 + 7e99929 commit 6636828

File tree

14 files changed

+136
-96
lines changed

14 files changed

+136
-96
lines changed

fillers/eips/eip3651.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,16 @@ def test_warm_coinbase_call_out_of_gas(fork):
118118
to_address(0x400): Account(code=staticcall_code),
119119
}
120120

121-
for i, data in enumerate(
122-
[to_hash(x) for x in range(0x100, 0x400 + 1, 0x100)]
123-
):
124-
121+
opcodes = {
122+
"call": 0x100,
123+
"callcode": 0x200,
124+
"delegatecall": 0x300,
125+
"staticcall": 0x400,
126+
}
127+
for opcode, data in opcodes.items():
125128
tx = Transaction(
126129
ty=0x0,
127-
data=data,
130+
data=to_hash(data),
128131
chain_id=0x0,
129132
nonce=0,
130133
to="0xcccccccccccccccccccccccccccccccccccccccc",
@@ -152,7 +155,13 @@ def test_warm_coinbase_call_out_of_gas(fork):
152155
}
153156
)
154157

155-
yield StateTest(env=env, pre=pre, post=post, txs=[tx])
158+
yield StateTest(
159+
env=env,
160+
pre=pre,
161+
post=post,
162+
txs=[tx],
163+
tag="opcode_" + opcode,
164+
)
156165

157166

158167
@test_from(fork="shanghai")
@@ -256,5 +265,5 @@ def test_warm_coinbase_gas_usage(fork):
256265
pre=pre,
257266
post=post,
258267
txs=[tx],
259-
name="warm_coinbase_opcode_" + opcode.lower(),
268+
tag="opcode_" + opcode.lower(),
260269
)

fillers/eips/eip3855.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ def test_push0(fork):
4545
pre[addr_1] = Account(code=code)
4646
post[addr_1] = Account(storage={0x00: 0x01})
4747

48-
yield StateTest(
49-
env=env, pre=pre, post=post, txs=[tx], name="push0_key_sstore"
50-
)
48+
yield StateTest(env=env, pre=pre, post=post, txs=[tx], tag="key_sstore")
5149

5250
"""
5351
Test case 2: Fill stack with PUSH0, then OR all values and save using
@@ -60,9 +58,7 @@ def test_push0(fork):
6058
pre[addr_1] = Account(code=code)
6159
post[addr_1] = Account(storage={0x00: 0x01})
6260

63-
yield StateTest(
64-
env=env, pre=pre, post=post, txs=[tx], name="push0_fill_stack"
65-
)
61+
yield StateTest(env=env, pre=pre, post=post, txs=[tx], tag="fill_stack")
6662

6763
"""
6864
Test case 3: Stack overflow by using PUSH0 1025 times
@@ -74,7 +70,7 @@ def test_push0(fork):
7470
post[addr_1] = Account(storage={0x00: 0x00})
7571

7672
yield StateTest(
77-
env=env, pre=pre, post=post, txs=[tx], name="push0_stack_overflow"
73+
env=env, pre=pre, post=post, txs=[tx], tag="stack_overflow"
7874
)
7975

8076
"""
@@ -88,7 +84,7 @@ def test_push0(fork):
8884
post[addr_1] = Account(storage={0x00: 0x02, 0x01: 0x00})
8985

9086
yield StateTest(
91-
env=env, pre=pre, post=post, txs=[tx], name="push0_storage_overwrite"
87+
env=env, pre=pre, post=post, txs=[tx], tag="storage_overwrite"
9288
)
9389

9490
"""
@@ -118,7 +114,7 @@ def test_push0(fork):
118114
post[addr_1] = Account(storage={0x00: 0x01, 0x01: 0xFF})
119115

120116
yield StateTest(
121-
env=env, pre=pre, post=post, txs=[tx], name="push0_during_staticcall"
117+
env=env, pre=pre, post=post, txs=[tx], tag="during_staticcall"
122118
)
123119

124120
del pre[addr_2]
@@ -141,7 +137,7 @@ def test_push0(fork):
141137
post[addr_1] = Account(storage={0x00: 0x01})
142138

143139
yield StateTest(
144-
env=env, pre=pre, post=post, txs=[tx], name="push0_before_jumpdest"
140+
env=env, pre=pre, post=post, txs=[tx], tag="before_jumpdest"
145141
)
146142

147143
"""
@@ -155,6 +151,4 @@ def test_push0(fork):
155151
pre[addr_1] = Account(code=code)
156152
post[addr_1] = Account(storage={0x00: 0x02})
157153

158-
yield StateTest(
159-
env=env, pre=pre, post=post, txs=[tx], name="push0_gas_cost"
160-
)
154+
yield StateTest(env=env, pre=pre, post=post, txs=[tx], tag="gas_cost")

fillers/eips/eip3860.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,69 +105,69 @@ def calculate_create_tx_execution_cost(
105105
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
106106
initcode_length=MAX_INITCODE_SIZE,
107107
padding_byte=0x01,
108-
name="max_size_ones_initcode",
108+
name="max_size_ones",
109109
)
110110

111111
INITCODE_ZEROS_MAX_LIMIT = Initcode(
112112
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
113113
initcode_length=MAX_INITCODE_SIZE,
114114
padding_byte=0x00,
115-
name="max_size_zeros_initcode",
115+
name="max_size_zeros",
116116
)
117117

118118
INITCODE_ONES_OVER_LIMIT = Initcode(
119119
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
120120
initcode_length=MAX_INITCODE_SIZE + 1,
121121
padding_byte=0x01,
122-
name="over_limit_ones_initcode",
122+
name="over_limit_ones",
123123
)
124124

125125
INITCODE_ZEROS_OVER_LIMIT = Initcode(
126126
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
127127
initcode_length=MAX_INITCODE_SIZE + 1,
128128
padding_byte=0x00,
129-
name="over_limit_zeros_initcode",
129+
name="over_limit_zeros",
130130
)
131131

132132
INITCODE_ZEROS_32_BYTES = Initcode(
133133
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
134134
initcode_length=32,
135135
padding_byte=0x00,
136-
name="32_bytes_initcode",
136+
name="32_bytes",
137137
)
138138

139139
INITCODE_ZEROS_33_BYTES = Initcode(
140140
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
141141
initcode_length=33,
142142
padding_byte=0x00,
143-
name="33_bytes_initcode",
143+
name="33_bytes",
144144
)
145145

146146
INITCODE_ZEROS_49120_BYTES = Initcode(
147147
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
148148
initcode_length=49120,
149149
padding_byte=0x00,
150-
name="49120_bytes_initcode",
150+
name="49120_bytes",
151151
)
152152

153153
INITCODE_ZEROS_49121_BYTES = Initcode(
154154
deploy_code=INITCODE_RESULTING_DEPLOYED_CODE,
155155
initcode_length=49121,
156156
padding_byte=0x00,
157-
name="49121_bytes_initcode",
157+
name="49121_bytes",
158158
)
159159

160160
EMPTY_INITCODE = Initcode(
161161
deploy_code=bytes(),
162-
name="empty_initcode",
162+
name="empty",
163163
)
164164
EMPTY_INITCODE.bytecode = bytes()
165165
EMPTY_INITCODE.deployment_gas = 0
166166
EMPTY_INITCODE.execution_gas = 0
167167

168168
SINGLE_BYTE_INITCODE = Initcode(
169169
deploy_code=bytes(),
170-
name="single_byte_initcode",
170+
name="single_byte",
171171
)
172172
SINGLE_BYTE_INITCODE.bytecode = Op.STOP
173173
SINGLE_BYTE_INITCODE.deployment_gas = 0
@@ -225,7 +225,7 @@ def generate_tx_initcode_limit_test_cases(
225225
post=post,
226226
blocks=[block],
227227
genesis_environment=env,
228-
name=f"initcode_tx_{initcode.name}",
228+
tag=f"{initcode.name}",
229229
)
230230

231231

@@ -315,7 +315,7 @@ def generate_gas_cost_test_cases(
315315
post=post,
316316
blocks=[block],
317317
genesis_environment=env,
318-
name=f"{initcode.name}_tx_exact_intrinsic_gas",
318+
tag=f"{initcode.name}_exact_intrinsic_gas",
319319
)
320320

321321
"""
@@ -341,7 +341,7 @@ def generate_gas_cost_test_cases(
341341
post=post,
342342
blocks=[block],
343343
genesis_environment=env,
344-
name=f"{initcode.name}_tx_under_intrinsic_gas",
344+
tag=f"{initcode.name}_under_intrinsic_gas",
345345
)
346346

347347
"""
@@ -367,7 +367,7 @@ def generate_gas_cost_test_cases(
367367
post=post,
368368
blocks=[block],
369369
genesis_environment=env,
370-
name=f"{initcode.name}_tx_under_execution_gas",
370+
tag=f"{initcode.name}_under_execution_gas",
371371
)
372372

373373
"""
@@ -388,7 +388,7 @@ def generate_gas_cost_test_cases(
388388
post=post,
389389
blocks=[block],
390390
genesis_environment=env,
391-
name=f"{initcode.name}_tx_exact_execution_gas",
391+
tag=f"{initcode.name}_exact_execution_gas",
392392
)
393393

394394

@@ -602,7 +602,7 @@ def generate_create_opcode_initcode_test_cases(
602602
pre=pre,
603603
post=post,
604604
txs=[tx],
605-
name=f"{opcode}_opcode_{initcode.name}",
605+
tag=f"{initcode.name}",
606606
)
607607

608608

0 commit comments

Comments
 (0)