Skip to content

test_callf_fibonacci()

Documentation for tests/osaka/eip7692_eof_v1/eip4750_functions/test_callf_execution.py::test_callf_fibonacci@21fb11c8.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip4750_functions/test_callf_execution.py::test_callf_fibonacci --fork Osaka

Test fibonacci sequence implementation with recursive CALLF instructions.

Source code in tests/osaka/eip7692_eof_v1/eip4750_functions/test_callf_execution.py
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
@pytest.mark.parametrize(
    "n,result",
    ((0, 1), (1, 1), (13, 233), (27, 196418)),
)
def test_callf_fibonacci(eof_state_test: EOFStateTestFiller, n, result):
    """Test fibonacci sequence implementation with recursive CALLF instructions."""
    eof_state_test(
        container=Container(
            sections=[
                Section.Code(
                    Op.CALLDATALOAD(0) + Op.SSTORE(0, Op.CALLF[1]) + Op.STOP,
                    max_stack_height=2,
                ),
                Section.Code(
                    Op.PUSH1[2]
                    + Op.DUP2
                    + Op.GT
                    + Op.RJUMPI[4]
                    + Op.POP
                    + Op.PUSH1[1]
                    + Op.RETF
                    + Op.PUSH1[2]
                    + Op.DUP2
                    + Op.SUB
                    + Op.CALLF[1]
                    + Op.PUSH1[1]
                    + Op.DUP3
                    + Op.SUB
                    + Op.CALLF[1]
                    + Op.ADD
                    + Op.SWAP1
                    + Op.POP
                    + Op.RETF,
                    code_inputs=1,
                    code_outputs=1,
                    max_stack_height=4,
                ),
            ]
        ),
        gas_limit=15_000_000,
        data=Hash(n),
        container_post=Account(storage={0: result}),
    )

Parametrized Test Cases

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

Test ID (Abbreviated) n result
...fork_Osaka-eof_test-n_0-result_1 0 1
...fork_Osaka-eof_test-n_1-result_1 1 1
...fork_Osaka-eof_test-n_13-result_233 13 233
...fork_Osaka-eof_test-n_27-result_196418 27 196418
...fork_Osaka-eof_state_test-n_0-result_1 0 1
...fork_Osaka-eof_state_test-n_1-result_1 1 1
...fork_Osaka-eof_state_test-n_13-result_233 13 233
...fork_Osaka-eof_state_test-n_27-result_196418 27 196418
...fork_Osaka-eof_blockchain_test-n_0-result_1 0 1
...fork_Osaka-eof_blockchain_test-n_1-result_1 1 1
...fork_Osaka-eof_blockchain_test-n_13-result_233 13 233
...fork_Osaka-eof_blockchain_test-n_27-result_196418 27 196418