Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
- ✨ Add test to validate withdarawls root ([#1746](https://github.com/ethereum/execution-specs/pull/1746)).

## [v5.3.0](https://github.com/ethereum/execution-spec-tests/releases/tag/v5.3.0) - 2025-10-09

Expand Down
48 changes: 48 additions & 0 deletions tests/shanghai/eip4895_withdrawals/test_withdrawals.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
TransactionException,
Withdrawal,
)
from execution_testing.exceptions.exceptions import BlockException
from execution_testing.forks import Cancun
from execution_testing.specs.blockchain import Header

from .spec import ref_spec_4895

Expand Down Expand Up @@ -249,6 +251,52 @@ def test_balance_within_block(
blockchain_test(pre=pre, post=post, blocks=blocks)


@pytest.mark.parametrize(
"valid", [True, pytest.param(False, marks=pytest.mark.exception_test)]
)
@pytest.mark.parametrize("n_withdrawals", [0, 1, 16])
def test_withdrawals_root(
blockchain_test: BlockchainTestFiller,
pre: Alloc,
valid: bool,
n_withdrawals: int,
) -> None:
"""
Test validation of withdrawals root.
"""
recipient = pre.fund_eoa(ONE_GWEI)
withdrawals = [
Withdrawal(
index=index,
validator_index=0,
address=recipient,
amount=1,
)
for index in range(n_withdrawals)
]

modified_fields = {
"withdrawals_root": Withdrawal.list_root(withdrawals)
if valid
else b"\x01" * 32
}

blocks = [
Block(
withdrawals=withdrawals,
rlp_modifier=Header(**modified_fields),
exception=[
BlockException.INVALID_WITHDRAWALS_ROOT,
BlockException.INVALID_BLOCK_HASH,
]
if not valid
else None,
),
]

blockchain_test(pre=pre, post={}, blocks=blocks)


@pytest.mark.parametrize("test_case", ["single_block", "multiple_blocks"])
class TestMultipleWithdrawalsSameAddress:
"""
Expand Down
Loading