Skip to content

test_transient_storage_unset_values()

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

Generate fixtures for these test cases for Osaka with:

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

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

Source code in tests/cancun/eip1153_tstore/test_tstorage.py
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
65
66
67
68
69
def test_transient_storage_unset_values(state_test: StateTestFiller, pre: Alloc) -> None:
    """
    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)",
    """
    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=dict.fromkeys(slots_under_test, 1),
    )

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

    post = {code_address: Account(storage=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