Skip to content

test_eof_example()

Documentation for tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_eof_example.py::test_eof_example@3719e927.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_eof_example.py::test_eof_example --fork Osaka

Example of python EOF classes.

Source code in tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_eof_example.py
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
57
58
59
60
61
62
def test_eof_example(eof_test: EOFTestFiller):
    """Example of python EOF classes."""
    # Lets construct an EOF container code
    eof_code = Container(
        name="valid_container_example",
        sections=[
            # TYPES section is constructed automatically based on CODE
            # CODE section
            Section.Code(
                code=Op.CALLF[1](Op.PUSH0) + Op.STOP,  # bytecode to be deployed in the body
                # Code: call section 1 with a single zero as input, then stop.
                max_stack_increase=1,  # define code header (in body) stack size
            ),
            # There can be multiple code sections
            Section.Code(
                # Remove input and call section 2 with no inputs, then remove output and return
                code=Op.POP + Op.CALLF[2]() + Op.POP + Op.RETF,
                code_inputs=1,
                code_outputs=0,
                max_stack_increase=0,
            ),
            Section.Code(
                # Call section 3 with two inputs (address twice), return
                code=Op.CALLF[3](Op.DUP1, Op.ADDRESS) + Op.POP + Op.POP + Op.RETF,
                code_outputs=1,
                max_stack_increase=3,
            ),
            Section.Code(
                # Duplicate one input and return
                code=Op.DUP1 + Op.RETF,
                code_inputs=2,
                code_outputs=3,
                max_stack_increase=1,
            ),
            # DATA section
            Section.Data("0xef"),
        ],
        expected_bytecode="ef00010100100200040005000600080002ff000100"
        "00800001 01000000 00010003 02030001"
        "5fe300010050e3000250e43080e300035050e480e4ef",
    )

    eof_test(
        container=eof_code,
        expect_exception=eof_code.validity_error,
    )

Parametrized Test Cases

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

Test ID (Abbreviated)
...fork_Osaka-eof_test
...fork_Osaka-state_test_from_eof_test
...fork_Osaka-blockchain_test_from_eof_test