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@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

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

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
 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
 99
100
101
102
@pytest.mark.valid_from("Cancun")
def test_tstore_clear_after_tx(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    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 generates 1 parametrized test case across 4 forks.