Skip to content

Commit 696040e

Browse files
committed
feat(tests): Add a case for RIPEMD OOGing in early forks
1 parent 9563a51 commit 696040e

File tree

2 files changed

+11
-61
lines changed

2 files changed

+11
-61
lines changed

tests/frontier/precompiles/test_ripemd.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
from execution_testing.vm import Opcodes as Op
1414

1515

16+
@pytest.mark.ported_from(
17+
# The oog==True case:
18+
[
19+
"https://github.com/ethereum/execution-specs/blob/master/tests/static/state_tests/stPreCompiledContracts2/CallRipemd160_0Filler.json"
20+
],
21+
pr=["https://github.com/ethereum/execution-spec-tests/pull/x"],
22+
)
1623
@pytest.mark.valid_from("Frontier")
1724
@pytest.mark.parametrize(
1825
"msg, output",
@@ -134,12 +141,14 @@
134141
),
135142
],
136143
)
144+
@pytest.mark.parametrize("oog", [True, False])
137145
def test_precompiles(
138146
state_test: StateTestFiller,
139147
pre: Alloc,
140148
fork: Fork,
141149
msg: bytes,
142150
output: bytes,
151+
oog: bool,
143152
) -> None:
144153
"""
145154
Tests the behavior of `RIPEMD-160` precompiled contract.
@@ -150,7 +159,7 @@ def test_precompiles(
150159
code=Op.CALLDATACOPY(0, 0, len(msg))
151160
+ Op.MLOAD(0)
152161
+ Op.CALL(
153-
gas=50_000,
162+
gas=50_000 if not oog else 255,
154163
address="0x03", # RIPEMD-160 precompile address
155164
args_offset=0,
156165
args_size=len(msg),
@@ -170,6 +179,6 @@ def test_precompiles(
170179
protected=fork >= Byzantium,
171180
)
172181

173-
post = {account: Account(storage={0: output})}
182+
post = {account: Account(storage={0: output if not oog else 0})}
174183

175184
state_test(env=env, pre=pre, post=post, tx=tx)

tests/static/state_tests/stPreCompiledContracts2/CallRipemd160_0Filler.json

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)