Skip to content

test_precompile_will_return_success_with_tx_value()

Documentation for tests/osaka/eip7951_p256verify_precompiles/test_p256verify.py::test_precompile_will_return_success_with_tx_value@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7951_p256verify_precompiles/test_p256verify.py::test_precompile_will_return_success_with_tx_value --fork Osaka

Test P256Verify precompile will not fail if value is sent.

Source code in tests/osaka/eip7951_p256verify_precompiles/test_p256verify.py
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
@pytest.mark.parametrize(
    "input_data,precompile_address,expected_output",
    [
        pytest.param(
            Spec.H0 + Spec.R0 + Spec.S0 + Spec.X0 + Spec.Y0,
            Spec.P256VERIFY,
            Spec.SUCCESS_RETURN_VALUE,
            id="valid_input_with_value_transfer",
        ),
    ],
)
@EIPChecklist.Precompile.Test.ValueTransfer.NoFee()
def test_precompile_will_return_success_with_tx_value(
    state_test: StateTestFiller,
    pre: Alloc,
    input_data: bytes,
    expected_output: bytes,
    precompile_address: Address,
) -> None:
    """Test P256Verify precompile will not fail if value is sent."""
    sender = pre.fund_eoa()
    storage = Storage()

    call_256verify_bytecode = (
        Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE())
        + Op.CALL(
            gas=Spec.P256VERIFY_GAS,
            address=Spec.P256VERIFY,
            value=Op.CALLVALUE(),
            args_offset=0,
            args_size=Op.CALLDATASIZE(),
            ret_offset=0,
            ret_size=32,
        )
        + Op.SSTORE(storage.store_next(True), Op.DUP1())
        + Op.SSTORE(storage.store_next(expected_output), Op.MLOAD(0))
        + Op.SSTORE(storage.store_next(len(expected_output)), Op.RETURNDATASIZE())
        + Op.STOP
    )

    contract_address = pre.deploy_contract(call_256verify_bytecode)
    tx = Transaction(
        sender=sender,
        gas_limit=1000000,
        to=contract_address,
        value=1000,
        data=input_data,
    )
    post = {contract_address: {"storage": storage}}
    state_test(env=Environment(), pre=pre, post=post, tx=tx)

Parametrized Test Cases

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

Test ID (Abbreviated) input_data precompile_address expected_output
...fork_Osaka-state_test-valid_input_with_value_transfer bb5a52f42f9c9261ed4361f59422a1e3 0036e7c32b270c8807a419feca605023 2ba3a8be6b94d5ec80a6d9d1190a436e ffe50d85a1eee859b8cc6af9bd5c2e18 4cd60b855d442f5b3c7b11eb6c4e0ae7 525fe710fab9aa7c77a67f79e6fadd76 2927b10512bae3eddcfe467828128bad 2903269919f7086069c8c4df6c732838 c7787964eaac00e5921fb1498a60f460 6766b3d9685001558d1a974e7341513e 256 00000000000000000000000000000000 00000000000000000000000000000001
...fork_Osaka-blockchain_test_from_state_test-valid_input_with_value_transfer bb5a52f42f9c9261ed4361f59422a1e3 0036e7c32b270c8807a419feca605023 2ba3a8be6b94d5ec80a6d9d1190a436e ffe50d85a1eee859b8cc6af9bd5c2e18 4cd60b855d442f5b3c7b11eb6c4e0ae7 525fe710fab9aa7c77a67f79e6fadd76 2927b10512bae3eddcfe467828128bad 2903269919f7086069c8c4df6c732838 c7787964eaac00e5921fb1498a60f460 6766b3d9685001558d1a974e7341513e 256 00000000000000000000000000000000 00000000000000000000000000000001