Skip to content

test_swapn_all_valid_immediates()

Documentation for tests/osaka/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_swapn.py::test_swapn_all_valid_immediates@21fb11c8.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_swapn.py::test_swapn_all_valid_immediates --fork Osaka

Test case for all valid SWAPN immediates.

Source code in tests/osaka/eip7692_eof_v1/eip663_dupn_swapn_exchange/test_swapn.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@pytest.mark.valid_from(EOF_FORK_NAME)
def test_swapn_all_valid_immediates(eof_state_test: EOFStateTestFiller):
    """Test case for all valid SWAPN immediates."""
    n = 256
    values = range(0x500, 0x500 + 257)

    eof_code = Container(
        sections=[
            Section.Code(
                code=sum(Op.PUSH2[v] for v in values)
                + sum(Op.SSTORE(x, Op.SWAPN[0xFF - x]) for x in range(0, n))
                + Op.STOP,
            )
        ],
    )

    values_rotated = list(values[1:]) + [values[0]]
    post = Account(storage=dict(zip(range(0, n), reversed(values_rotated), strict=False)))

    eof_state_test(
        tx_sender_funding_amount=1_000_000_000,
        container=eof_code,
        container_post=post,
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Osaka-eof_test
...fork_Osaka-eof_state_test
...fork_Osaka-eof_blockchain_test