Skip to content

test_tload_after_tstore()

Documentation for tests/cancun/eip1153_tstore/test_tstorage.py::test_tload_after_tstore@f6ab9733.

Generate fixtures for these test cases for Cancun with:

Cancun only:

fill -v tests/cancun/eip1153_tstore/test_tstorage.py::test_tload_after_tstore --fork=Cancun --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Cancun:

fill -v tests/cancun/eip1153_tstore/test_tstorage.py::test_tload_after_tstore --until=Cancun

Loading after storing returns the stored value: TSTORE(x, y), TLOAD(x) returns y.

Based on ethereum/tests/.../02_tloadAfterTstoreFiller.yml", # noqa: E501

Source code in tests/cancun/eip1153_tstore/test_tstorage.py
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
85
86
87
88
89
90
91
def test_tload_after_tstore(state_test: StateTestFiller, pre: Alloc):
    """
    Loading after storing returns the stored value: TSTORE(x, y), TLOAD(x)
    returns y.

    Based on [ethereum/tests/.../02_tloadAfterTstoreFiller.yml](https://github.com/ethereum/tests/blob/9b00b68593f5869eb51a6659e1cc983e875e616b/src/EIPTestsFiller/StateTests/stEIP1153-transientStorage/02_tloadAfterTstoreFiller.yml)",  # noqa: E501
    """
    env = Environment()

    slots_under_test = [0, 1, 2, 2**128, 2**256 - 1]
    code = sum(
        Op.TSTORE(slot, slot) + Op.SSTORE(slot, Op.TLOAD(slot)) for slot in slots_under_test
    )
    code_address = pre.deploy_contract(
        code=code,  # type: ignore
        storage={slot: 0xFF for slot in slots_under_test},
    )

    tx = Transaction(
        sender=pre.fund_eoa(),
        to=code_address,
        gas_limit=1_000_000,
    )

    post = {code_address: Account(storage={slot: slot for slot in slots_under_test})}

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