Skip to content

test_emission_point_fork_transition()

Documentation for tests/amsterdam/eip7708_eth_transfer_logs/test_fork_transition.py::test_emission_point_fork_transition@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7708_eth_transfer_logs/test_fork_transition.py::test_emission_point_fork_transition --fork Amsterdam

Test the CALL, CREATE, and SELFDESTRUCT emission points at the fork transition boundary.

Clients gate each emission site in a separate code path, so every site is checked at the transition independently of the transaction-level log.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_fork_transition.py
 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
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
@pytest.mark.parametrize(
    "emission_point",
    [
        pytest.param("call", id="call"),
        pytest.param("create", id="create"),
        pytest.param("selfdestruct", id="selfdestruct"),
    ],
)
@pytest.mark.valid_at_transition_to("EIP7708")
def test_emission_point_fork_transition(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    emission_point: str,
) -> None:
    """
    Test the CALL, CREATE, and SELFDESTRUCT emission points at the fork
    transition boundary.

    Clients gate each emission site in a separate code path, so every
    site is checked at the transition independently of the
    transaction-level log.
    """
    sender = pre.fund_eoa()
    value = 100
    recipient = pre.deploy_contract(Op.STOP)

    if emission_point == "call":
        code = Op.CALL(address=recipient, value=Op.CALLVALUE)
    elif emission_point == "create":
        code = Op.CREATE(value=Op.CALLVALUE, offset=0, size=0)
    else:
        code = Op.SELFDESTRUCT(recipient)
    contract = pre.deploy_contract(code)

    blocks = []
    for nonce, (timestamp, active) in enumerate(
        [(14_999, False), (15_000, True), (15_001, True)], start=1
    ):
        if emission_point == "create":
            inner_recipient = compute_create_address(
                address=contract, nonce=nonce
            )
        else:
            inner_recipient = recipient
        logs = (
            [
                transfer_log(sender, contract, value),
                transfer_log(contract, inner_recipient, value),
            ]
            if active
            else []
        )
        blocks.append(
            Block(
                timestamp=timestamp,
                txs=[
                    Transaction(
                        to=contract,
                        sender=sender,
                        value=value,
                        expected_receipt=TransactionReceipt(logs=logs),
                    )
                ],
            )
        )

    if emission_point == "create":
        post = {
            compute_create_address(address=contract, nonce=nonce): Account(
                balance=value
            )
            for nonce in (1, 2, 3)
        }
    else:
        post = {recipient: Account(balance=3 * value)}

    blockchain_test(pre=pre, blocks=blocks, post=post)

Parametrized Test Cases

This test generates 3 parametrized test cases across 1 fork.