Skip to content

test_blake2b_large_gas_limit()

Documentation for tests/istanbul/eip152_blake2/test_blake2.py::test_blake2b_large_gas_limit@b314d18e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/istanbul/eip152_blake2/test_blake2.py::test_blake2b_large_gas_limit --fork Amsterdam

Test BLAKE2b precompile with large gas limit.

Source code in tests/istanbul/eip152_blake2/test_blake2.py
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
@pytest.mark.valid_from("Istanbul")
@pytest.mark.parametrize("call_opcode", [Op.CALL, Op.CALLCODE])
@pytest.mark.parametrize(
    ["data", "output"],
    [
        pytest.param(
            Blake2bInput(
                rounds=100_000,
            ),
            ExpectedOutput(
                data_1="0x165da71a32e91bca2623bfaeab079f7e6edfba2259028cc854ec497f9fb0fe75",
                data_2="0xd37f63034b83f4a0a07cd238483874862921ef0c40630826a76e41bf3b02ffe3",
            ),
            id="EIP-152-modified-case8-data9-large-gas-limit",
        ),
        pytest.param(
            Blake2bInput(
                rounds=8000000,
            ),
            ExpectedOutput(
                data_1="0x6d2ce9e534d50e18ff866ae92d70cceba79bbcd14c63819fe48752c8aca87a4b",
                data_2="0xb7dcc230d22a4047f0486cfcfb50a17b24b2899eb8fca370f22240adb5170189",
            ),
            id="EIP-152-case8-data9-large-gas-limit",
            marks=pytest.mark.skip("Times-out during fill"),
        ),
    ],
)
@pytest.mark.slow()
def test_blake2b_large_gas_limit(
    state_test: StateTestFiller,
    pre: Alloc,
    call_opcode: Op,
    blake2b_contract_bytecode: Bytecode,
    data: Blake2bInput | bytes,
    output: ExpectedOutput,
) -> None:
    """Test BLAKE2b precompile with large gas limit."""
    account = pre.deploy_contract(
        blake2b_contract_bytecode, storage={0: 0xDEADBEEF}
    )
    sender = pre.fund_eoa()

    tx = Transaction(to=account, data=data, sender=sender)

    post = {
        account: Account(storage={0: 0x1, 1: output.data_1, 2: output.data_2})
    }
    state_test(pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test generates 4 parametrized test cases across 9 forks.