func testBuiltinEcho()

in sdk/swift/TeaclaveClientSDK/TeaclaveClientSDKTests/TeaclaveClientSDKTests.swift [32:72]


    func testBuiltinEcho() throws {
        let client = AuthenticationClient(
            address: authentication_service_address,
            enclave_info_path: enclave_info_path,
            as_root_ca_cert_path: as_root_ca_cert_path
        )!
        let token = try client.login(id: "admin", password: "teacalve").get()

        let register_function_request = RegisterFunctionRequest(
            name: "builtin-echo",
            description: "Native Echo Function",
            executor_type: "builtin",
            payload: [],
            arguments: ["message"],
            inputs: [],
            outputs: []
        )

        let frontend_client = FrontendClient(
            address: frontend_service_address,
            enclave_info_path: enclave_info_path,
            as_root_ca_cert_path: as_root_ca_cert_path
        )!
        try frontend_client.set_credential(id: "test_id", token: token).get()
        let response = try frontend_client.register_function(with: register_function_request).get()
        let function_id = response.function_id

        let create_task_request = CreateTaskRequest(
            function_id: function_id,
            function_arguments: "{\"message\": \"Hello, Teaclave!\"}",
            executor: "builtin",
            inputs_ownership: [],
            outputs_ownership: []
        )

        let task_id = try frontend_client.create_task(with: create_task_request).get().task_id

        try frontend_client.invoke_task(task_id: task_id).get()
        let task_result = try frontend_client.get_task_result(task_id: task_id).get()
        XCTAssert(task_result == "Hello, Teaclave!")
    }