Skip to content

test_transient_storage_unset_values()

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

Generate fixtures for these test cases for Prague with:

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

Test that tload returns zero for unset values. Loading an arbitrary value is 0 at beginning of transaction: TLOAD(x) is 0.

Based on ethereum/tests/.../01_tloadBeginningTxnFiller.yml",

Source code in tests/cancun/eip1153_tstore/test_tstorage.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def test_transient_storage_unset_values(state_test: StateTestFiller, pre: Alloc):
    """
    Test that tload returns zero for unset values. Loading an arbitrary value is
    0 at beginning of transaction: TLOAD(x) is 0.

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

    slots_under_test = [0, 1, 2, 2**128, 2**256 - 1]
    code = sum(Op.SSTORE(slot, Op.TLOAD(slot)) for slot in slots_under_test)

    code_address = pre.deploy_contract(
        code=code,  # type: ignore
        storage={slot: 1 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: 0 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