Skip to content

test_bal_consolidation_contract_cross_index()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_cross_index.py::test_bal_consolidation_contract_cross_index@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_cross_index.py::test_bal_consolidation_contract_cross_index --fork Amsterdam

Test that the consolidation system contract shows storage changes at both index 1 (during transaction) and index 2 (during post-execution).

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_cross_index.py
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
def test_bal_consolidation_contract_cross_index(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
) -> None:
    """
    Test that the consolidation system contract shows storage changes at both
    index 1 (during transaction) and index 2 (during post-execution).
    """
    sender = pre.fund_eoa()

    consolidation_calldata = (
        (b"\x01" + b"\x00" * 47)  # source pubkey
        + (b"\x02" + b"\x00" * 47)  # target pubkey
    )

    tx = Transaction(
        sender=sender,
        to=CONSOLIDATION_REQUEST_ADDRESS,
        value=1,
        data=consolidation_calldata,
        gas_limit=1_000_000,
    )

    blockchain_test(
        pre=pre,
        blocks=[
            Block(
                txs=[tx],
                expected_block_access_list=BlockAccessListExpectation(
                    account_expectations={
                        CONSOLIDATION_REQUEST_ADDRESS: BalAccountExpectation(
                            storage_changes=[
                                BalStorageSlot(
                                    slot=0x01,
                                    slot_changes=[
                                        BalStorageChange(
                                            # Incremented during tx
                                            block_access_index=1,
                                            post_value=1,
                                        ),
                                        BalStorageChange(
                                            # Reset during post-exec
                                            block_access_index=2,
                                            post_value=0,
                                        ),
                                    ],
                                ),
                                BalStorageSlot(
                                    slot=0x03,
                                    slot_changes=[
                                        BalStorageChange(
                                            # Incremented during tx
                                            block_access_index=1,
                                            post_value=1,
                                        ),
                                        BalStorageChange(
                                            # Reset during post-exec
                                            block_access_index=2,
                                            post_value=0,
                                        ),
                                    ],
                                ),
                            ],
                        ),
                    }
                ),
            )
        ],
        post={},
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.