Skip to content

test_tload_after_tstore_is_zero()

Documentation for tests/cancun/eip1153_tstore/test_tstorage.py::test_tload_after_tstore_is_zero@21fb11c8.

Generate fixtures for these test cases for Prague with:

fill -v tests/cancun/eip1153_tstore/test_tstorage.py::test_tload_after_tstore_is_zero --fork Prague

Test that tload returns zero after tstore is called with zero.

Based on ethereum/tests/.../03_tloadAfterStoreIs0Filler.yml",

Source code in tests/cancun/eip1153_tstore/test_tstorage.py
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
def test_tload_after_tstore_is_zero(state_test: StateTestFiller, pre: Alloc):
    """
    Test that tload returns zero after tstore is called with zero.

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

    slots_to_write = [1, 4, 2**128, 2**256 - 2]
    slots_to_read = [slot - 1 for slot in slots_to_write] + [slot + 1 for slot in slots_to_write]
    assert set.intersection(set(slots_to_write), set(slots_to_read)) == set()

    code = sum(Op.TSTORE(slot, 1234) for slot in slots_to_write) + sum(
        Op.SSTORE(slot, Op.TLOAD(slot)) for slot in slots_to_read
    )

    code_address = pre.deploy_contract(
        code=code,  # type: ignore
        storage={slot: 0xFFFF for slot in slots_to_write + slots_to_read},
    )

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

    post = {
        code_address: Account(
            storage={slot: 0 for slot in slots_to_read} | {slot: 0xFFFF for slot in slots_to_write}
        )
    }

    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