Skip to content

test_pointer_contract_pointer_loop()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py::test_pointer_contract_pointer_loop@01f496f4.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py::test_pointer_contract_pointer_loop --fork Prague

Tx -> call -> pointer A -> contract A -> pointer B -> contract loop C.

Call pointer that goes more level of depth to call a contract loop Loop is created only if pointers are set with auth tuples

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
79
80
81
82
83
84
85
86
87
88
@pytest.mark.valid_from("Prague")
def test_pointer_contract_pointer_loop(state_test: StateTestFiller, pre: Alloc):
    """
    Tx -> call -> pointer A -> contract A -> pointer B -> contract loop C.

    Call pointer that goes more level of depth to call a contract loop
    Loop is created only if pointers are set with auth tuples
    """
    env = Environment()

    sender = pre.fund_eoa()
    pointer_a = pre.fund_eoa()
    pointer_b = pre.fund_eoa()

    storage: Storage = Storage()
    contract_a = pre.deploy_contract(
        code=Op.SSTORE(storage.store_next(1, "contract_a_worked"), 0x1)
        + Op.CALL(gas=1_000_000, address=pointer_b)
        + Op.STOP,
    )

    storage_loop: Storage = Storage()
    contract_worked = storage_loop.store_next(112, "contract_loop_worked")
    contract_loop = pre.deploy_contract(
        code=Op.SSTORE(contract_worked, Op.ADD(1, Op.SLOAD(0)))
        + Op.CALL(gas=1_000_000, address=pointer_a)
        + Op.STOP,
    )
    tx = Transaction(
        to=pointer_a,
        gas_limit=1_000_000,
        data=b"",
        value=0,
        sender=sender,
        authorization_list=[
            AuthorizationTuple(
                address=contract_a,
                nonce=0,
                signer=pointer_a,
            ),
            AuthorizationTuple(
                address=contract_loop,
                nonce=0,
                signer=pointer_b,
            ),
        ],
    )

    post = {
        pointer_a: Account(storage=storage),
        pointer_b: Account(storage=storage_loop),
    }
    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Prague-state_test
...fork_Prague-blockchain_test_from_state_test
...fork_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test