Skip to content

Test Tstorage Reentrancy Contexts

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

Generate fixtures for these test cases with:

fill -v tests/cancun/eip1153_tstore/test_tstorage_reentrancy_contexts.py
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
@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=Hash(1),
        gas_limit=10_000_000,
    )

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

    state_test(env=env, pre=pre, post=post, tx=tx)