Skip to content

Commit f097a33

Browse files
authored
benchmark: fix calldatacopy in low gas fillings (#1889)
Signed-off-by: Ignacio Hagopian <[email protected]>
1 parent 73e2d89 commit f097a33

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tests/benchmark/test_worst_memory.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ def test_worst_calldatacopy(
7777
if size == 0 and non_zero_data:
7878
pytest.skip("Non-zero data with size 0 is not applicable.")
7979

80+
# If `non_zero_data` is True, we fill the calldata with deterministic random data.
81+
# Note that if `size == 0` and `non_zero_data` is a skipped case.
82+
data = Bytes([i % 256 for i in range(size)]) if non_zero_data else Bytes()
83+
84+
intrinsic_gas_calculator = fork.transaction_intrinsic_cost_calculator()
85+
min_gas = intrinsic_gas_calculator(calldata=data)
86+
if min_gas > env.gas_limit:
87+
pytest.skip("Minimum gas required for calldata ({min_gas}) is greater than the gas limit")
88+
8089
# We create the contract that will be doing the CALLDATACOPY multiple times.
8190
#
8291
# If `non_zero_data` is True, we leverage CALLDATASIZE for the copy length. Otherwise, since we
@@ -105,10 +114,6 @@ def test_worst_calldatacopy(
105114
)
106115
tx_target = pre.deploy_contract(code=code)
107116

108-
# If `non_zero_data` is True, we fill the calldata with deterministic random data.
109-
# Note that if `size == 0` and `non_zero_data` is a skipped case.
110-
data = Bytes([i % 256 for i in range(size)]) if non_zero_data else Bytes()
111-
112117
tx = Transaction(
113118
to=tx_target,
114119
gas_limit=env.gas_limit,

0 commit comments

Comments
 (0)