Skip to content

test_tstore_clear_after_tx()

Documentation for tests/cancun/eip1153_tstore/test_tstorage_clear_after_tx.py::test_tstore_clear_after_tx@83970623.

Generate fixtures for these test cases for Prague with:

fill -v tests/cancun/eip1153_tstore/test_tstorage_clear_after_tx.py::test_tstore_clear_after_tx --fork Prague

First SSTOREs the TLOAD value of key 1 in slot 1. Then, it TSTOREs 1 in slot 1. The second tx will re-call the contract. The storage should stay empty, because the transient storage is cleared after the transaction.

Source code in tests/cancun/eip1153_tstore/test_tstorage_clear_after_tx.py
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
@pytest.mark.valid_from("Cancun")
@pytest.mark.with_all_evm_code_types
def test_tstore_clear_after_tx(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
):
    """
    First SSTOREs the TLOAD value of key 1 in slot 1. Then, it TSTOREs 1 in slot 1.
    The second tx will re-call the contract. The storage should stay empty,
    because the transient storage is cleared after the transaction.
    """
    env = Environment()

    code = Op.SSTORE(1, Op.TLOAD(1)) + Op.TSTORE(1, 1)
    account = pre.deploy_contract(code)

    sender = pre.fund_eoa()

    poke_tstore_tx = Transaction(
        gas_limit=100000,
        to=account,
        sender=sender,
    )

    re_poke_tstore_tx = Transaction(gas_limit=100000, to=account, sender=sender)

    txs = [poke_tstore_tx, re_poke_tstore_tx]

    post = {
        account: Account(storage={0x01: 0x00}),
    }

    blockchain_test(genesis_environment=env, pre=pre, post=post, blocks=[Block(txs=txs)])

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated) evm_code_type
...fork_Cancun-evm_code_type_LEGACY-blockchain_test LEGACY
...fork_Prague-evm_code_type_LEGACY-blockchain_test LEGACY
...fork_Osaka-evm_code_type_LEGACY-blockchain_test LEGACY
...fork_Osaka-evm_code_type_EOF_V1-blockchain_test EOF_V1