Skip to content

test_bal_withdrawal_and_value_transfer_same_address()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip4895.py::test_bal_withdrawal_and_value_transfer_same_address@20373115.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip4895.py::test_bal_withdrawal_and_value_transfer_same_address --fork Amsterdam

Ensure BAL captures both value transfer and withdrawal to same address.

Alice starts with 1 ETH, Bob starts with 0. Alice sends 5 gwei to Bob. Bob receives withdrawal of 10 gwei. Bob ends with 15 gwei (5 from tx + 10 from withdrawal).

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip4895.py
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
def test_bal_withdrawal_and_value_transfer_same_address(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
) -> None:
    """
    Ensure BAL captures both value transfer and withdrawal to same address.

    Alice starts with 1 ETH, Bob starts with 0.
    Alice sends 5 gwei to Bob.
    Bob receives withdrawal of 10 gwei.
    Bob ends with 15 gwei (5 from tx + 10 from withdrawal).
    """
    alice = pre.fund_eoa()
    bob = pre.fund_eoa(amount=0)

    tx = Transaction(
        sender=alice,
        to=bob,
        value=5 * GWEI,
        gas_price=0xA,
    )

    block = Block(
        txs=[tx],
        withdrawals=[
            Withdrawal(
                index=0,
                validator_index=0,
                address=bob,
                amount=10,
            )
        ],
        expected_block_access_list=BlockAccessListExpectation(
            account_expectations={
                alice: BalAccountExpectation(
                    nonce_changes=[
                        BalNonceChange(block_access_index=1, post_nonce=1)
                    ],
                ),
                bob: BalAccountExpectation(
                    balance_changes=[
                        BalBalanceChange(
                            block_access_index=1, post_balance=5 * GWEI
                        ),
                        BalBalanceChange(
                            block_access_index=2, post_balance=15 * GWEI
                        ),
                    ],
                ),
            }
        ),
    )

    blockchain_test(
        pre=pre,
        blocks=[block],
        post={
            alice: Account(nonce=1),
            bob: Account(balance=15 * GWEI),
        },
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.