Skip to content

test_slotnum_mainnet()

Documentation for tests/amsterdam/eip7843_slotnum/test_eip_mainnet.py::test_slotnum_mainnet@b314d18e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7843_slotnum/test_eip_mainnet.py::test_slotnum_mainnet --fork Amsterdam

Test that SLOTNUM is callable and returns a non-zero slot number.

Asserts on POP(SLOTNUM) rather than the slot value itself so the test remains valid when execute-ed against a live network, where the slot number is whatever the consensus layer transmits and cannot be controlled by the test.

Source code in tests/amsterdam/eip7843_slotnum/test_eip_mainnet.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def test_slotnum_mainnet(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    Test that SLOTNUM is callable and returns a non-zero slot number.

    Asserts on ``POP(SLOTNUM)`` rather than the slot value itself
    so the test remains valid when ``execute``-ed against a live network,
    where the slot number is whatever the consensus layer transmits and
    cannot be controlled by the test.
    """
    contract = pre.deploy_contract(
        code=Op.POP(Op.SLOTNUM) + Op.SSTORE(0, 1),
        storage={"0x00": "0xdeadbeef"},
    )
    tx = Transaction(
        ty=0x02,
        to=contract,
        sender=pre.fund_eoa(),
        gas_limit=200_000,
    )
    post = {contract: Account(storage={"0x00": 1})}

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post=post,
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.