Skip to content

test_tload_after_sstore()

Documentation for tests/cancun/eip1153_tstore/test_tstorage.py::test_tload_after_sstore@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

fill -v tests/cancun/eip1153_tstore/test_tstorage.py::test_tload_after_sstore --fork Osaka

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

Based on [ethereum/tests/.../18_tloadAfterStoreFiller.yml] (https://github.com/ethereum/tests/blob/ 9b00b68/src/ EIPTestsFiller/StateTests/stEIP1153-transientStorage/ 18_tloadAfterStoreFiller.yml)",

Source code in tests/cancun/eip1153_tstore/test_tstorage.py
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
def test_tload_after_sstore(state_test: StateTestFiller, pre: Alloc) -> None:
    """
    Loading after storing returns the stored value: TSTORE(x, y), TLOAD(x)
    returns y.

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

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

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

    post = {
        code_address: Account(
            code=code,
            storage={slot - 1: 0xFF for slot in slots_under_test}
            | dict.fromkeys(slots_under_test, 0),
        )
    }

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

Parametrized Test Cases

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

Test ID (Abbreviated)
...fork_Cancun-state_test
...fork_Cancun-blockchain_test_from_state_test
...fork_Prague-state_test
...fork_Prague-blockchain_test_from_state_test
...fork_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test