Skip to content

Commit 12aceb8

Browse files
fix incorrect logic for missing coverage
1 parent 50b6b30 commit 12aceb8

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

src/ethereum_test_specs/benchmark.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def generate_repeated_code(
6666
available_space = max_code_size - overhead
6767
max_iterations = available_space // len(repeated_code)
6868

69-
code = setup + Op.JUMPDEST + repeated_code * max_iterations + cleanup + Op.JUMP(len(setup))
69+
# TODO: Unify the PUSH0 and PUSH1 usage.
70+
code = setup + Op.JUMPDEST + repeated_code * max_iterations + cleanup
71+
code += Op.JUMP(len(setup)) if len(setup) > 0 else Op.PUSH0 + Op.JUMP
7072
self._validate_code_size(code, fork)
7173

7274
return code

tests/benchmark/test_worst_bytecode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def test_worst_create(
408408
)
409409

410410
code = JumpLoopGenerator(setup=setup, attack_block=attack_block).generate_repeated_code(
411-
attack_block, Bytecode(), Bytecode(), fork
411+
repeated_code=attack_block, setup=setup, cleanup=Bytecode(), fork=fork
412412
)
413413

414414
tx = Transaction(

tests/benchmark/test_worst_compute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def test_worst_calldatasize(
101101
) -> None:
102102
"""Test running a block with as many CALLDATASIZE as possible."""
103103
tx = JumpLoopGenerator(
104-
setup=Bytecode(), attack_block=Op.POP(Op.CALLDATASIZE)
104+
setup=Bytecode(), attack_block=Op.POP(Op.CALLDATASIZE), cleanup=Bytecode()
105105
).generate_transaction(pre, gas_benchmark_value, fork)
106106
tx.data = Bytes(b"\x00" * calldata_length)
107107

tests/benchmark/test_worst_memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def test_worst_codecopy(
166166
attack_block = Op.CODECOPY(src_dst, src_dst, Op.DUP1) # DUP1 copies size.
167167

168168
code = JumpLoopGenerator(setup=setup, attack_block=attack_block).generate_repeated_code(
169-
attack_block, Bytecode(), Bytecode(), fork
169+
repeated_code=attack_block, setup=setup, cleanup=Bytecode(), fork=fork
170170
)
171171

172172
# The code generated above is not guaranteed to be of max_code_size, so

0 commit comments

Comments
 (0)