Skip to content

test_eofcreate_then_call()

Documentation for tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_eofcreate_then_call@[email protected].

Generate fixtures for these test cases for Pragueeip7692 with:

Pragueeip7692 only:

fill -v tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_eofcreate_then_call --fork=PragueEIP7692 --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Pragueeip7692:

fill -v tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_eofcreate_then_call --until=PragueEIP7692

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

Source code in tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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)