Skip to content

test_yul()

Documentation for tests/homestead/yul/test_yul_example.py::test_yul@83970623.

Generate fixtures for these test cases for Prague with:

fill -v tests/homestead/yul/test_yul_example.py::test_yul --fork Prague

Test YUL compiled bytecode.

Source code in tests/homestead/yul/test_yul_example.py
16
17
18
19
20
21
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
56
@pytest.mark.valid_from("Homestead")
def test_yul(state_test: StateTestFiller, pre: Alloc, yul: YulCompiler, fork: Fork):
    """Test YUL compiled bytecode."""
    env = Environment()

    contract_address = pre.deploy_contract(
        code=yul(
            """
            {
                function f(a, b) -> c {
                    c := add(a, b)
                }

                sstore(0, f(1, 2))
                return(0, 32)
            }
            """
        ),
        balance=0x0BA1A9CE0BA1A9CE,
    )
    sender = pre.fund_eoa(amount=0x0BA1A9CE0BA1A9CE)

    tx = Transaction(
        ty=0x0,
        chain_id=0x01,
        sender=sender,
        to=contract_address,
        gas_limit=500000,
        gas_price=10,
        protected=False if fork in [Frontier, Homestead] else True,
    )

    post = {
        contract_address: Account(
            storage={
                0x00: 0x03,
            },
        ),
    }

    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_Homestead-blockchain_test
...fork_Homestead-state_test
...fork_Byzantium-blockchain_test
...fork_Byzantium-state_test
...fork_Constantinople-blockchain_test
...fork_Constantinople-state_test
...fork_ConstantinopleFix-blockchain_test
...fork_ConstantinopleFix-state_test
...fork_Istanbul-blockchain_test
...fork_Istanbul-state_test
...fork_Berlin-blockchain_test
...fork_Berlin-state_test
...fork_London-blockchain_test
...fork_London-state_test
...fork_Paris-blockchain_test
...fork_Paris-state_test
...fork_Shanghai-blockchain_test
...fork_Shanghai-state_test
...fork_Cancun-blockchain_test
...fork_Cancun-state_test
...fork_Prague-blockchain_test
...fork_Prague-state_test
...fork_Osaka-blockchain_test
...fork_Osaka-state_test