Skip to content

test_bal_invalid_withdrawal_balance_value()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_withdrawal_balance_value@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_withdrawal_balance_value --fork Amsterdam

Test that clients reject blocks where BAL contains an incorrect balance value for an account modified only by a withdrawal.

Charlie receives a 10 gwei withdrawal in an empty block. BAL is corrupted by changing Charlie's post-balance to 999 instead of the correct 10_000_000_000 (10 gwei in wei).

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.exception_test
def test_bal_invalid_withdrawal_balance_value(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    Test that clients reject blocks where BAL contains an incorrect
    balance value for an account modified only by a withdrawal.

    Charlie receives a 10 gwei withdrawal in an empty block.
    BAL is corrupted by changing Charlie's post-balance to 999 instead
    of the correct 10_000_000_000 (10 gwei in wei).
    """
    charlie = pre.fund_eoa(amount=0)

    blockchain_test(
        pre=pre,
        post={
            charlie: None,
        },
        blocks=[
            Block(
                txs=[],
                withdrawals=[
                    Withdrawal(
                        index=0,
                        validator_index=0,
                        address=charlie,
                        amount=10,
                    )
                ],
                exception=BlockException.INVALID_BLOCK_ACCESS_LIST,
                expected_block_access_list=BlockAccessListExpectation(
                    account_expectations={
                        charlie: BalAccountExpectation(
                            balance_changes=[
                                BalBalanceChange(
                                    block_access_index=1,
                                    post_balance=10 * 10**9,
                                )
                            ],
                        ),
                    }
                ).modify(
                    modify_balance(charlie, block_access_index=1, balance=999)
                ),
            )
        ],
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.