Skip to content

test_ext_code_on_self_set_code()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_ext_code_on_self_set_code@verkle@v0.0.6.

Generate fixtures for these test cases for Prague with:

Prague only:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_ext_code_on_self_set_code --fork=Prague --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Prague:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_ext_code_on_self_set_code --until=Prague

Test different ext*code operations on self set-code address.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
@pytest.mark.parametrize(
    "balance",
    [0, 1],
)
def test_ext_code_on_self_set_code(
    state_test: StateTestFiller,
    pre: Alloc,
    balance: int,
):
    """
    Test different ext*code operations on self set-code address.
    """
    auth_signer = pre.fund_eoa(balance)

    slot = count(1)
    slot_ext_code_size_result = next(slot)
    slot_ext_code_hash_result = next(slot)
    slot_ext_code_copy_result = next(slot)
    slot_ext_balance_result = next(slot)

    set_code = (
        Op.SSTORE(slot_ext_code_size_result, Op.EXTCODESIZE(auth_signer))
        + Op.SSTORE(slot_ext_code_hash_result, Op.EXTCODEHASH(auth_signer))
        + Op.EXTCODECOPY(auth_signer, 0, 0, Op.EXTCODESIZE(auth_signer))
        + Op.SSTORE(slot_ext_code_copy_result, Op.MLOAD(0))
        + Op.SSTORE(slot_ext_balance_result, Op.BALANCE(auth_signer))
        + Op.STOP
    )
    set_code_address = pre.deploy_contract(set_code)

    set_code_storage = Storage()
    set_code_storage[slot_ext_code_size_result] = len(set_code)
    set_code_storage[slot_ext_code_hash_result] = set_code.keccak256()
    set_code_storage[slot_ext_code_copy_result] = bytes(set_code).ljust(32, b"\x00")[:32]
    set_code_storage[slot_ext_balance_result] = balance

    tx = Transaction(
        gas_limit=10_000_000,
        to=auth_signer,
        authorization_list=[
            AuthorizationTuple(
                address=set_code_address,
                nonce=0,
                signer=auth_signer,
            ),
        ],
        sender=pre.fund_eoa(),
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            auth_signer: Account(storage=set_code_storage),
        },
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID balance
balance_0 0
balance_1 1
balance_0 0
balance_1 1