Skip to content

Commit 43e710c

Browse files
refactor: optimize jumpdest test case (#1732)
* refactor: optimize jumpdest test case * refactor(tests): streamline jumpdest contract creation in worst compute test * Update tests/zkevm/test_worst_compute.py --------- Co-authored-by: Mario Vega <[email protected]>
1 parent 9c75235 commit 43e710c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

tests/zkevm/test_worst_compute.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -801,15 +801,13 @@ def test_worst_jumpdests(state_test: StateTestFiller, pre: Alloc, fork: Fork):
801801
max_code_size = fork.max_code_size()
802802

803803
# Create and deploy a contract with many JUMPDESTs
804-
jumpdests_code = sum([Op.JUMPDEST] * max_code_size)
805-
jumpdests_address = pre.deploy_contract(code=bytes(jumpdests_code))
806-
807-
# Call the contract repeatedly until gas runs out.
808-
caller_code = While(body=Op.POP(Op.CALL(address=jumpdests_address)))
809-
caller_address = pre.deploy_contract(caller_code)
804+
code_suffix = Op.JUMP(Op.PUSH0)
805+
code_body = Op.JUMPDEST * (max_code_size - len(code_suffix))
806+
code = code_body + code_suffix
807+
jumpdests_address = pre.deploy_contract(code=code)
810808

811809
tx = Transaction(
812-
to=caller_address,
810+
to=jumpdests_address,
813811
gas_limit=env.gas_limit,
814812
sender=pre.fund_eoa(),
815813
)

0 commit comments

Comments
 (0)