Skip to content

test_balance_within_block()

Documentation for tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_balance_within_block@21fb11c8.

Generate fixtures for these test cases for Prague with:

fill -v tests/shanghai/eip4895_withdrawals/test_withdrawals.py::test_balance_within_block --fork Prague

Test Withdrawal balance increase within the same block, inside contract call.

Source code in tests/shanghai/eip4895_withdrawals/test_withdrawals.py
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
def test_balance_within_block(blockchain_test: BlockchainTestFiller, pre: Alloc):
    """
    Test Withdrawal balance increase within the same block,
    inside contract call.
    """
    save_balance_on_block_number = Op.SSTORE(
        Op.NUMBER,
        Op.BALANCE(Op.CALLDATALOAD(0)),
    )
    sender = pre.fund_eoa()
    recipient = pre.fund_eoa(ONE_GWEI)
    contract_address = pre.deploy_contract(save_balance_on_block_number)

    blocks = [
        Block(
            txs=[
                Transaction(
                    sender=sender,
                    gas_limit=100000,
                    to=contract_address,
                    data=Hash(recipient, left_padding=True),
                )
            ],
            withdrawals=[
                Withdrawal(
                    index=0,
                    validator_index=0,
                    address=recipient,
                    amount=1,
                )
            ],
        ),
        Block(
            txs=[
                Transaction(
                    sender=sender,
                    gas_limit=100000,
                    to=contract_address,
                    data=Hash(recipient, left_padding=True),
                )
            ]
        ),
    ]

    post = {
        contract_address: Account(
            storage={
                1: ONE_GWEI,
                2: 2 * ONE_GWEI,
            }
        )
    }

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

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated)
...fork_Shanghai-blockchain_test
...fork_Cancun-blockchain_test
...fork_Prague-blockchain_test
...fork_Osaka-blockchain_test