Skip to content

test_tload_after_tstore()

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

Generate fixtures for these test cases for Amsterdam with:

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

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/ 9b00b68/src/EIPTestsFiller/StateTests/ stEIP1153-transientStorage/02_tloadAfterTstoreFiller.yml)",

Source code in tests/cancun/eip1153_tstore/test_tstorage.py
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
def test_tload_after_tstore(state_test: StateTestFiller, pre: Alloc) -> None:
    """
    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)",
    """
    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=dict.fromkeys(slots_under_test, 0xFF),
    )

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

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

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

Parametrized Test Cases

This test generates 1 parametrized test case across 4 forks.