Skip to content

test_combinations()

Documentation for tests/constantinople/eip145_bitwise_shift/test_shift_combinations.py::test_combinations@64f949d0.

Generate fixtures for these test cases for Prague with:

fill -v tests/constantinople/eip145_bitwise_shift/test_shift_combinations.py::test_combinations --fork Prague

Test bitwise shift combinations.

Source code in tests/constantinople/eip145_bitwise_shift/test_shift_combinations.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
@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"],
)
def test_combinations(state_test: StateTestFiller, pre: Alloc, opcode: Op, operation: Callable):
    """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,
        gas_limit=5_000_000,
    )

    state_test(pre=pre, post={address_to: Account(storage=result)}, tx=tx)

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) opcode operation
...fork_Constantinople-state_test-sar SAR
...fork_Constantinople-state_test-shl SHL
...fork_Constantinople-state_test-shr SHR
...fork_Constantinople-blockchain_test_from_state_test-sar SAR
...fork_Constantinople-blockchain_test_from_state_test-shl SHL
...fork_Constantinople-blockchain_test_from_state_test-shr SHR
...fork_ConstantinopleFix-state_test-sar SAR
...fork_ConstantinopleFix-state_test-shl SHL
...fork_ConstantinopleFix-state_test-shr SHR
...fork_ConstantinopleFix-blockchain_test_from_state_test-sar SAR
...fork_ConstantinopleFix-blockchain_test_from_state_test-shl SHL
...fork_ConstantinopleFix-blockchain_test_from_state_test-shr SHR
...fork_Istanbul-state_test-sar SAR
...fork_Istanbul-state_test-shl SHL
...fork_Istanbul-state_test-shr SHR
...fork_Istanbul-blockchain_test_from_state_test-sar SAR
...fork_Istanbul-blockchain_test_from_state_test-shl SHL
...fork_Istanbul-blockchain_test_from_state_test-shr SHR
...fork_Berlin-state_test-sar SAR
...fork_Berlin-state_test-shl SHL
...fork_Berlin-state_test-shr SHR
...fork_Berlin-blockchain_test_from_state_test-sar SAR
...fork_Berlin-blockchain_test_from_state_test-shl SHL
...fork_Berlin-blockchain_test_from_state_test-shr SHR
...fork_London-state_test-sar SAR
...fork_London-state_test-shl SHL
...fork_London-state_test-shr SHR
...fork_London-blockchain_test_from_state_test-sar SAR
...fork_London-blockchain_test_from_state_test-shl SHL
...fork_London-blockchain_test_from_state_test-shr SHR
...fork_Paris-state_test-sar SAR
...fork_Paris-state_test-shl SHL
...fork_Paris-state_test-shr SHR
...fork_Paris-blockchain_test_from_state_test-sar SAR
...fork_Paris-blockchain_test_from_state_test-shl SHL
...fork_Paris-blockchain_test_from_state_test-shr SHR
...fork_Shanghai-state_test-sar SAR
...fork_Shanghai-state_test-shl SHL
...fork_Shanghai-state_test-shr SHR
...fork_Shanghai-blockchain_test_from_state_test-sar SAR
...fork_Shanghai-blockchain_test_from_state_test-shl SHL
...fork_Shanghai-blockchain_test_from_state_test-shr SHR
...fork_Cancun-state_test-sar SAR
...fork_Cancun-state_test-shl SHL
...fork_Cancun-state_test-shr SHR
...fork_Cancun-blockchain_test_from_state_test-sar SAR
...fork_Cancun-blockchain_test_from_state_test-shl SHL
...fork_Cancun-blockchain_test_from_state_test-shr SHR
...fork_Prague-state_test-sar SAR
...fork_Prague-state_test-shl SHL
...fork_Prague-state_test-shr SHR
...fork_Prague-blockchain_test_from_state_test-sar SAR
...fork_Prague-blockchain_test_from_state_test-shl SHL
...fork_Prague-blockchain_test_from_state_test-shr SHR
...fork_Osaka-state_test-sar SAR
...fork_Osaka-state_test-shl SHL
...fork_Osaka-state_test-shr SHR
...fork_Osaka-blockchain_test_from_state_test-sar SAR
...fork_Osaka-blockchain_test_from_state_test-shl SHL
...fork_Osaka-blockchain_test_from_state_test-shr SHR