Skip to content

test_blob_tx_attribute_opcodes()

Documentation for tests/cancun/eip4844_blobs/test_blob_txs.py::test_blob_tx_attribute_opcodes@21fb11c8.

Generate fixtures for these test cases for Prague with:

fill -v tests/cancun/eip4844_blobs/test_blob_txs.py::test_blob_tx_attribute_opcodes --fork Prague

Test opcodes that read transaction attributes work properly for blob type transactions.

  • ORIGIN
  • CALLER
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
@pytest.mark.parametrize(
    "opcode",
    [Op.ORIGIN, Op.CALLER],
    indirect=["opcode"],
)
@pytest.mark.parametrize("tx_gas", [500_000])
@pytest.mark.valid_from("Cancun")
def test_blob_tx_attribute_opcodes(
    state_test: StateTestFiller,
    pre: Alloc,
    sender: EOA,
    tx_value: int,
    tx_gas: int,
    tx_calldata: bytes,
    tx_max_fee_per_gas: int,
    tx_max_fee_per_blob_gas: int,
    tx_max_priority_fee_per_gas: int,
    tx_access_list: List[AccessList],
    blob_hashes_per_tx: List[List[bytes]],
    opcode: Tuple[Bytecode, Storage.StorageDictType],
    state_env: Environment,
):
    """
    Test opcodes that read transaction attributes work properly for blob type transactions.

    - ORIGIN
    - CALLER
    """
    code, storage = opcode
    destination_account = pre.deploy_contract(code=code)
    tx = Transaction(
        ty=Spec.BLOB_TX_TYPE,
        sender=sender,
        to=destination_account,
        value=tx_value,
        gas_limit=tx_gas,
        data=tx_calldata,
        max_fee_per_gas=tx_max_fee_per_gas,
        max_priority_fee_per_gas=tx_max_priority_fee_per_gas,
        max_fee_per_blob_gas=tx_max_fee_per_blob_gas,
        access_list=tx_access_list,
        blob_versioned_hashes=blob_hashes_per_tx[0],
    )
    post = {
        destination_account: Account(
            storage=storage,
        )
    }
    state_test(
        pre=pre,
        post=post,
        tx=tx,
        env=state_env,
    )

Parametrized Test Cases

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

Test ID (Abbreviated) opcode tx_gas
...fork_Cancun-state_test-tx_gas_500000-opcode_ORIGIN ORIGIN 500000
...fork_Cancun-state_test-tx_gas_500000-opcode_CALLER CALLER 500000
...fork_Cancun-blockchain_test_from_state_test-tx_gas_500000-opcode_ORIGIN ORIGIN 500000
...fork_Cancun-blockchain_test_from_state_test-tx_gas_500000-opcode_CALLER CALLER 500000
...fork_Prague-state_test-tx_gas_500000-opcode_ORIGIN ORIGIN 500000
...fork_Prague-state_test-tx_gas_500000-opcode_CALLER CALLER 500000
...fork_Prague-blockchain_test_from_state_test-tx_gas_500000-opcode_ORIGIN ORIGIN 500000
...fork_Prague-blockchain_test_from_state_test-tx_gas_500000-opcode_CALLER CALLER 500000
...fork_Osaka-state_test-tx_gas_500000-opcode_ORIGIN ORIGIN 500000
...fork_Osaka-state_test-tx_gas_500000-opcode_CALLER CALLER 500000
...fork_Osaka-blockchain_test_from_state_test-tx_gas_500000-opcode_ORIGIN ORIGIN 500000
...fork_Osaka-blockchain_test_from_state_test-tx_gas_500000-opcode_CALLER CALLER 500000