Skip to content

test_eofcreate_then_call()

Documentation for tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_eofcreate_then_call@21fb11c8.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_eofcreate_then_call --fork Osaka

Verifies a simple EOFCREATE case, and then calls the deployed contract.

Source code in tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
def test_eofcreate_then_call(
    state_test: StateTestFiller,
    pre: Alloc,
):
    """Verifies a simple EOFCREATE case, and then calls the deployed contract."""
    env = Environment()
    callable_contract = Container(
        sections=[
            Section.Code(
                code=Op.SSTORE(slot_code_worked, value_code_worked) + Op.STOP,
            ),
        ]
    )
    callable_contract_initcode = Container(
        sections=[
            Section.Code(
                code=Op.RETURNCONTRACT[0](0, 0),
            ),
            Section.Container(container=callable_contract),
        ]
    )

    sender = pre.fund_eoa()
    contract_address = pre.deploy_contract(
        Container(
            sections=[
                Section.Code(
                    code=Op.SSTORE(slot_create_address, Op.EOFCREATE[0](0, 0, 0, 0))
                    + Op.EXTCALL(Op.SLOAD(slot_create_address), 0, 0, 0)
                    + Op.SSTORE(slot_code_worked, value_code_worked)
                    + Op.STOP,
                ),
                Section.Container(container=callable_contract_initcode),
            ],
        )
    )

    callable_address = compute_eofcreate_address(contract_address, 0, callable_contract_initcode)

    # Storage in 0 should have the address,
    #
    post = {
        contract_address: Account(
            storage={slot_create_address: callable_address, slot_code_worked: value_code_worked}
        ),
        callable_address: Account(storage={slot_code_worked: value_code_worked}),
    }

    tx = Transaction(
        to=contract_address,
        gas_limit=10_000_000,
        gas_price=10,
        protected=False,
        sender=sender,
    )
    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_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test