@pytest.mark.parametrize(
"opcode,operation",
[
pytest.param(Op.SAR, Spec.sar, id="sar"),
pytest.param(Op.SHL, Spec.shl, id="shl"),
pytest.param(Op.SHR, Spec.shr, id="shr"),
],
)
@pytest.mark.valid_from("Constantinople")
@pytest.mark.ported_from(
[
"https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stShift/shiftCombinationsFiller.yml",
"https://github.com/ethereum/tests/blob/v13.3/src/GeneralStateTestsFiller/stShift/shiftSignedCombinationsFiller.yml",
],
pr=["https://github.com/ethereum/execution-spec-tests/pull/1683"],
)
@pytest.mark.eels_base_coverage
def test_combinations(
state_test: StateTestFiller, pre: Alloc, opcode: Op, operation: Callable
) -> None:
"""Test bitwise shift combinations."""
result = Storage()
address_to = pre.deploy_contract(
code=sum(
Op.SSTORE(
result.store_next(
operation(shift=a, value=b),
f"{str(opcode).lower()}({a}, {b})",
),
opcode(a, b),
)
for a, b in combinations
)
+ Op.SSTORE(result.store_next(1, "code_finished"), 1)
+ Op.STOP,
)
tx = Transaction(
sender=pre.fund_eoa(),
to=address_to,
)
state_test(pre=pre, post={address_to: Account(storage=result)}, tx=tx)