Skip to content

test_tstore_clear_after_deployment_tx()

Documentation for tests/cancun/eip1153_tstore/test_tstorage_clear_after_tx.py::test_tstore_clear_after_deployment_tx@26332146.

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_deployment_tx --fork Amsterdam

First creates a contract, which TSTOREs a value 1 in slot 1. After creating the contract, a new tx will call this contract, storing TLOAD(1) into slot 1. The transient storage should be cleared after creating the contract (at tx-level), so the storage should stay empty.

Source code in tests/cancun/eip1153_tstore/test_tstorage_clear_after_tx.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@pytest.mark.valid_from("Cancun")
def test_tstore_clear_after_deployment_tx(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    First creates a contract, which TSTOREs a value 1 in slot 1. After creating
    the contract, a new tx will call this contract, storing TLOAD(1) into slot
    1. The transient storage should be cleared after creating the contract (at
    tx-level), so the storage should stay empty.
    """
    init_code = Op.TSTORE(1, 1)
    deploy_code = Op.SSTORE(1, Op.TLOAD(1))

    code = Initcode(deploy_code=deploy_code, initcode_prefix=init_code)

    sender = pre.fund_eoa()

    deployment_tx = Transaction(data=code, to=None, sender=sender)

    address = deployment_tx.created_contract

    invoke_contract_tx = Transaction(to=address, sender=sender)

    txs = [deployment_tx, invoke_contract_tx]

    post = {
        address: 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.