Skip to content

Commit d9705ec

Browse files
fix: resolve failing blob and block has tests
1 parent 878d058 commit d9705ec

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

tests/benchmark/test_worst_compute.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,9 @@ def test_worst_blobhash(
16671667
if blobs_present > 0:
16681668
tx.ty = HexNumber(TransactionType.BLOB_TRANSACTION)
16691669
tx.max_fee_per_blob_gas = HexNumber(fork.min_base_fee_per_blob_gas())
1670+
tx.max_fee_per_gas = HexNumber(1000)
1671+
tx.max_priority_fee_per_gas = HexNumber(0)
1672+
tx.access_list = []
16701673
tx.blob_versioned_hashes = add_kzg_version(
16711674
[i.to_bytes() * 32 for i in range(blobs_present)],
16721675
BlobsSpec.BLOB_COMMITMENT_VERSION_KZG,

tests/benchmark/test_worst_stateful_opcodes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import pytest
99

10+
from ethereum_test_base_types import HexNumber
1011
from ethereum_test_benchmark.benchmark_code_generator import ExtCallGenerator, JumpLoopGenerator
1112
from ethereum_test_forks import Fork
1213
from ethereum_test_specs import StateTestFiller
@@ -442,7 +443,7 @@ def test_worst_blockhash(
442443
# Create 256 dummy blocks to fill the blockhash window.
443444
blocks = [Block()] * 256
444445

445-
code = ExtCallGenerator(setup=Bytecode(), attack_block=Op.BLOCKHASH(0)).generate_repeated_code(
446+
code = ExtCallGenerator(setup=Bytecode(), attack_block=Op.BLOCKHASH(1)).generate_repeated_code(
446447
repeated_code=Op.BLOCKHASH(1),
447448
setup=Bytecode(),
448449
cleanup=Bytecode(),
@@ -452,16 +453,14 @@ def test_worst_blockhash(
452453
iteration_count = math.ceil(gas_benchmark_value / tx_gas_limit_cap)
453454
code_address = pre.deploy_contract(code=code)
454455

456+
gas_remaining = gas_benchmark_value
455457
txs = []
456-
for i in range(iteration_count):
457-
tx_gas_limit = (
458-
tx_gas_limit_cap
459-
if i != iteration_count - 1
460-
else gas_benchmark_value % tx_gas_limit_cap
461-
)
458+
for _ in range(iteration_count):
459+
tx_gas_limit = min(tx_gas_limit_cap, gas_remaining)
460+
gas_remaining -= tx_gas_limit
462461
tx = Transaction(
463462
to=code_address,
464-
gas_limit=tx_gas_limit,
463+
gas_limit=HexNumber(tx_gas_limit),
465464
sender=pre.fund_eoa(),
466465
)
467466
txs.append(tx)
@@ -471,6 +470,7 @@ def test_worst_blockhash(
471470
pre=pre,
472471
post={},
473472
blocks=blocks,
473+
expected_benchmark_gas_used=gas_benchmark_value,
474474
)
475475

476476

0 commit comments

Comments
 (0)