diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index df43e0f9c5..55ad44ebd1 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -29,6 +29,7 @@ Test fixtures for use by clients are available for each release on the [Github r - ✨ Expand cases to test *CALL opcodes causing OOG ([#1703](https://github.com/ethereum/execution-specs/pull/1703)). - ✨ Add tests for `modexp` and `ripemd` precompiled contracts ([#1691](https://github.com/ethereum/execution-specs/pull/1691)). - ✨ Add `ecrecover` precompile tests originating form `evmone` unittests ([#1685](https://github.com/ethereum/execution-specs/pull/1685)). +- ✨ Ported tests for `ripemd` precompile going OOG for all forks ([#1732](https://github.com/ethereum/execution-specs/pull/1732)). ## [v5.3.0](https://github.com/ethereum/execution-spec-tests/releases/tag/v5.3.0) - 2025-10-09 diff --git a/tests/frontier/precompiles/test_ripemd.py b/tests/frontier/precompiles/test_ripemd.py index bd72690eb6..dc34ce1ad8 100644 --- a/tests/frontier/precompiles/test_ripemd.py +++ b/tests/frontier/precompiles/test_ripemd.py @@ -13,6 +13,13 @@ from execution_testing.vm import Opcodes as Op +@pytest.mark.ported_from( + # The oog==True case: + [ + "https://github.com/ethereum/execution-specs/blob/master/tests/static/state_tests/stPreCompiledContracts2/CallRipemd160_0Filler.json" + ], + pr=["https://github.com/ethereum/execution-specs/pull/1732"], +) @pytest.mark.valid_from("Frontier") @pytest.mark.parametrize( "msg, output", @@ -134,12 +141,14 @@ ), ], ) +@pytest.mark.parametrize("oog", [True, False]) def test_precompiles( state_test: StateTestFiller, pre: Alloc, fork: Fork, msg: bytes, output: bytes, + oog: bool, ) -> None: """ Tests the behavior of `RIPEMD-160` precompiled contract. @@ -150,7 +159,7 @@ def test_precompiles( code=Op.CALLDATACOPY(0, 0, len(msg)) + Op.MLOAD(0) + Op.CALL( - gas=50_000, + gas=50_000 if not oog else 255, address="0x03", # RIPEMD-160 precompile address args_offset=0, args_size=len(msg), @@ -170,6 +179,6 @@ def test_precompiles( protected=fork >= Byzantium, ) - post = {account: Account(storage={0: output})} + post = {account: Account(storage={0: output if not oog else 0})} state_test(env=env, pre=pre, post=post, tx=tx) diff --git a/tests/static/state_tests/stPreCompiledContracts2/CallRipemd160_0Filler.json b/tests/static/state_tests/stPreCompiledContracts2/CallRipemd160_0Filler.json deleted file mode 100644 index 24ed4ca9ae..0000000000 --- a/tests/static/state_tests/stPreCompiledContracts2/CallRipemd160_0Filler.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "CallRipemd160_0" : { - "env" : { - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", - "currentDifficulty" : "0x20000", - "currentGasLimit" : "10000000", - "currentNumber" : "1", - "currentTimestamp" : "1000" - }, - "expect" : [ - { - "indexes" : { - "data" : -1, - "gas" : -1, - "value" : -1 - }, - "network" : [">=Cancun"], - "result" : { - "" : { - "storage" : { - "0x00" : "0x01" - } - } - } - } - ], - "pre" : { - "" : { - "balance" : "20000000", - "code" : "0x600160005260206000602060006000600360fff1600051600055", - "nonce" : "0", - "storage" : { - } - }, - "" : { - "balance" : "1000000000000000000", - "code" : "", - "nonce" : "0", - "storage" : { - } - } - }, - "transaction" : { - "data" : [ - "" - ], - "gasLimit" : [ - "365224" - ], - "gasPrice" : "10", - "nonce" : "0", - "secretKey" : "", - "to" : "", - "value" : [ - "100000" - ] - } - } -}