Skip to content

test_bal_invalid_tx_order()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_tx_order@20373115.

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_tx_order --fork Amsterdam

Test that clients reject blocks where BAL has incorrect transaction ordering.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.exception_test
def test_bal_invalid_tx_order(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    Test that clients reject blocks where BAL has incorrect transaction
    ordering.
    """
    sender1 = pre.fund_eoa(amount=10**18)
    sender2 = pre.fund_eoa(amount=10**18)
    receiver = pre.fund_eoa(amount=0)

    tx1 = Transaction(
        sender=sender1,
        to=receiver,
        value=10**15,
        gas_limit=21_000,
    )

    tx2 = Transaction(
        sender=sender2,
        to=receiver,
        value=2 * 10**15,
        gas_limit=21_000,
    )

    blockchain_test(
        pre=pre,
        post={
            sender1: Account(balance=10**18, nonce=0),
            sender2: Account(balance=10**18, nonce=0),
            receiver: None,
        },
        blocks=[
            Block(
                txs=[tx1, tx2],
                exception=BlockException.INVALID_BLOCK_ACCESS_LIST,
                expected_block_access_list=BlockAccessListExpectation(
                    account_expectations={
                        sender1: BalAccountExpectation(
                            nonce_changes=[
                                BalNonceChange(
                                    block_access_index=1, post_nonce=1
                                )
                            ],
                        ),
                        sender2: BalAccountExpectation(
                            nonce_changes=[
                                BalNonceChange(
                                    block_access_index=2, post_nonce=1
                                )
                            ],
                        ),
                        receiver: BalAccountExpectation(
                            balance_changes=[
                                BalBalanceChange(
                                    block_access_index=1, post_balance=10**15
                                ),
                                BalBalanceChange(
                                    block_access_index=2,
                                    post_balance=3 * 10**15,
                                ),
                            ],
                        ),
                    }
                ).modify(swap_bal_indices(1, 2)),
            )
        ],
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.