Skip to content

test_push0_contract_during_call_contexts()

Documentation for tests/shanghai/eip3855_push0/test_push0.py::TestPush0CallContext::test_push0_contract_during_call_contexts@verkle@v0.0.6.

Generate fixtures for these test cases for Shanghai with:

Shanghai only:

fill -v tests/shanghai/eip3855_push0/test_push0.py::TestPush0CallContext::test_push0_contract_during_call_contexts --fork=Shanghai --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Shanghai:

fill -v tests/shanghai/eip3855_push0/test_push0.py::TestPush0CallContext::test_push0_contract_during_call_contexts --until=Shanghai

Tests the PUSH0 operation during various call contexts including: - CALL - CALLCODE - DELEGATECALL - STATICCALL

Source code in tests/shanghai/eip3855_push0/test_push0.py
 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
139
140
141
142
143
144
145
146
147
148
149
150
class TestPush0CallContext:
    """
    Tests the PUSH0 operation during various call contexts including:
    - CALL
    - CALLCODE
    - DELEGATECALL
    - STATICCALL
    """

    @pytest.fixture
    def push0_contract_callee(self, pre: Alloc) -> Address:
        """
        Deploys a PUSH0 contract callee to the pre alloc returning its address.
        """
        push0_contract = pre.deploy_contract(Op.MSTORE8(Op.PUSH0, 0xFF) + Op.RETURN(Op.PUSH0, 1))
        return push0_contract

    @pytest.fixture
    def push0_contract_caller(
        self, pre: Alloc, call_opcode: Op, push0_contract_callee: Address
    ) -> Address:
        """
        Deploys a contract responsible for calling the callee PUSH0 contract returning its address.
        """
        call_code = (
            Op.SSTORE(0, call_opcode(gas=100_000, address=push0_contract_callee))
            + Op.SSTORE(0, 1)
            + Op.RETURNDATACOPY(0x1F, 0, 1)
            + Op.SSTORE(1, Op.MLOAD(0))
        )
        return pre.deploy_contract(call_code)

    @pytest.mark.parametrize(
        "call_opcode",
        [
            Op.CALL,
            Op.CALLCODE,
            Op.DELEGATECALL,
            Op.STATICCALL,
        ],
        ids=["call", "callcode", "delegatecall", "staticcall"],
    )
    def test_push0_contract_during_call_contexts(
        self,
        state_test: StateTestFiller,
        env: Environment,
        pre: Alloc,
        post: Alloc,
        sender: EOA,
        push0_contract_caller: Address,
    ):
        """
        Test PUSH0 during various call contexts.
        """
        tx = Transaction(to=push0_contract_caller, gas_limit=100_000, sender=sender)
        post[push0_contract_caller] = Account(storage={0x00: 0x01, 0x01: 0xFF})
        state_test(env=env, pre=pre, post=post, tx=tx)

test_push0_contract_during_call_contexts(state_test, env, pre, post, sender, push0_contract_caller)

Test PUSH0 during various call contexts.

Source code in tests/shanghai/eip3855_push0/test_push0.py
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
@pytest.mark.parametrize(
    "call_opcode",
    [
        Op.CALL,
        Op.CALLCODE,
        Op.DELEGATECALL,
        Op.STATICCALL,
    ],
    ids=["call", "callcode", "delegatecall", "staticcall"],
)
def test_push0_contract_during_call_contexts(
    self,
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    post: Alloc,
    sender: EOA,
    push0_contract_caller: Address,
):
    """
    Test PUSH0 during various call contexts.
    """
    tx = Transaction(to=push0_contract_caller, gas_limit=100_000, sender=sender)
    post[push0_contract_caller] = Account(storage={0x00: 0x01, 0x01: 0xFF})
    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID call_opcode
call CALL
callcode CALLCODE
delegatecall DELEGATECALL
staticcall STATICCALL
call CALL
callcode CALLCODE
delegatecall DELEGATECALL
staticcall STATICCALL