Skip to content

Test Tstorage Reentrancy Contexts

Documentation for tests/cancun/eip1153_tstore/test_tstorage_reentrancy_contexts.py.

Generate fixtures for these test cases for Cancun with:

Cancun only:

fill -v tests/cancun/eip1153_tstore/test_tstorage_reentrancy_contexts.py --fork=Cancun --evm-bin=/path/to/evm-tool-dev-version
For all forks up to and including Cancun:
fill -v tests/cancun/eip1153_tstore/test_tstorage_reentrancy_contexts.py --until=Cancun --evm-bin=/path/to/evm-tool-dev-version

abstract: Tests for EIP-1153: Transient Storage

Test cases for `TSTORE` and `TLOAD` opcode calls in reentrancy contexts.

test_reentrant_call(state_test, bytecode, expected_storage)

Test transient storage in different reentrancy contexts.

Source code in tests/cancun/eip1153_tstore/test_tstorage_reentrancy_contexts.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
@ReentrancyTestCases.parametrize()
def test_reentrant_call(state_test: StateTestFiller, bytecode, expected_storage):
    """
    Test transient storage in different reentrancy contexts.
    """
    env = Environment()

    pre = {
        TestAddress: Account(balance=10**40),
        callee_address: Account(code=bytecode),
    }

    tx = Transaction(
        to=callee_address,
        data=to_hash_bytes(1),
        gas_limit=10_000_000,
    )

    post = {callee_address: Account(code=bytecode, storage=expected_storage)}

    state_test(env=env, pre=pre, post=post, txs=[tx])