Skip to content

test_blake2_precompile_delegatecall()

Documentation for tests/istanbul/eip152_blake2/test_blake2_delegatecall.py::test_blake2_precompile_delegatecall@44293f1e.

Generate fixtures for these test cases for Prague with:

fill -v tests/istanbul/eip152_blake2/test_blake2_delegatecall.py::test_blake2_precompile_delegatecall --fork Prague

Test delegatecall consumes specified gas for the Blake2B precompile when it exists.

Source code in tests/istanbul/eip152_blake2/test_blake2_delegatecall.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@pytest.mark.valid_from("ConstantinopleFix")
def test_blake2_precompile_delegatecall(state_test: StateTestFiller, pre: Alloc, fork: Fork):
    """Test delegatecall consumes specified gas for the Blake2B precompile when it exists."""
    env = Environment()

    account = pre.deploy_contract(
        Op.SSTORE(
            0,
            Op.DELEGATECALL(
                gas=1,
                address=Spec.BLAKE2_PRECOMPILE_ADDRESS,
            ),
        )
        + Op.STOP,
        storage={0: 0xDEADBEEF},
    )

    tx = Transaction(
        to=account,
        sender=pre.fund_eoa(),
        gas_limit=90_000,
        protected=True,
    )

    # If precompile exists, DELEGATECALL will fail, otherwise DELEGATECALL will succeed
    post = {
        account: Account(
            storage={
                0: "0x00" if fork >= Istanbul else "0x01",
            }
        )
    }

    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_ConstantinopleFix-state_test
...fork_ConstantinopleFix-blockchain_test_from_state_test
...fork_Istanbul-state_test
...fork_Istanbul-blockchain_test_from_state_test
...fork_Berlin-state_test
...fork_Berlin-blockchain_test_from_state_test
...fork_London-state_test
...fork_London-blockchain_test_from_state_test
...fork_Paris-state_test
...fork_Paris-blockchain_test_from_state_test
...fork_Shanghai-state_test
...fork_Shanghai-blockchain_test_from_state_test
...fork_Cancun-state_test
...fork_Cancun-blockchain_test_from_state_test
...fork_Prague-state_test
...fork_Prague-blockchain_test_from_state_test
...fork_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test