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@343274cc.

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
@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.
    """
    code = Op.SSTORE(1, Op.TLOAD(1)) + Op.TSTORE(1, 1)
    account = pre.deploy_contract(code)

    sender = pre.fund_eoa()

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

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

    txs = [poke_tstore_tx, re_poke_tstore_tx]

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

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

Parametrized Test Cases

This test generates 1 parametrized test case across 4 forks.