Skip to content

test_tload_after_tstore()

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

Generate fixtures for these test cases for Prague with:

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

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

Based on ethereum/tests/.../02_tloadAfterTstoreFiller.yml",

Source code in tests/cancun/eip1153_tstore/test_tstorage.py
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
92
93
94
95
96
97
98
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,
    )

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