From 323c9ad341cf6ec42681263e29f011790351bc41 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Fri, 17 Jan 2025 10:46:21 +0000 Subject: [PATCH 1/3] Regenerate and update dependencies --- Package.swift | 4 +-- .../Generated/health.grpc.swift | 8 +++--- Sources/GRPCHealthService/HealthService.swift | 4 ++- .../Generated/empty.grpc.swift | 24 ++++++++++++++++ .../Generated/empty_service.grpc.swift | 8 +++--- .../Generated/messages.grpc.swift | 26 +++++++++++++++++ .../Generated/test.grpc.swift | 24 ++++++++-------- .../InteroperabilityTestCase.swift | 2 +- .../InteroperabilityTestCases.swift | 28 +++++++++---------- .../Generated/reflection.grpc.swift | 8 +++--- .../Service/ReflectionService.swift | 4 ++- .../GRPCHealthServiceTests/HealthTests.swift | 5 +++- .../ReflectionClient.swift | 5 ++-- 13 files changed, 104 insertions(+), 46 deletions(-) create mode 100644 Sources/GRPCInteropTests/Generated/empty.grpc.swift create mode 100644 Sources/GRPCInteropTests/Generated/messages.grpc.swift diff --git a/Package.swift b/Package.swift index 6bc10c0..4bed48c 100644 --- a/Package.swift +++ b/Package.swift @@ -39,11 +39,11 @@ let products: [Product] = [ let dependencies: [Package.Dependency] = [ .package( url: "https://github.com/grpc/grpc-swift.git", - exact: "2.0.0-beta.2" + branch: "main" ), .package( url: "https://github.com/grpc/grpc-swift-protobuf.git", - exact: "1.0.0-beta.2" + branch: "main" ), .package( url: "https://github.com/apple/swift-protobuf.git", diff --git a/Sources/GRPCHealthService/Generated/health.grpc.swift b/Sources/GRPCHealthService/Generated/health.grpc.swift index 70535cf..d9b235d 100644 --- a/Sources/GRPCHealthService/Generated/health.grpc.swift +++ b/Sources/GRPCHealthService/Generated/health.grpc.swift @@ -299,7 +299,7 @@ extension Grpc_Health_V1_Health { // Default implementation of 'registerMethods(with:)'. extension Grpc_Health_V1_Health.StreamingServiceProtocol { - package func registerMethods(with router: inout GRPCCore.RPCRouter) { + package func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport { router.registerHandler( forMethod: Grpc_Health_V1_Health.Method.Check.descriptor, deserializer: GRPCProtobuf.ProtobufDeserializer(), @@ -477,14 +477,14 @@ extension Grpc_Health_V1_Health { /// > Health is gRPC's mechanism for checking whether a server is able to handle /// > RPCs. Its semantics are documented in /// > https://github.com/grpc/grpc/blob/master/doc/health-checking.md. - package struct Client: ClientProtocol { - private let client: GRPCCore.GRPCClient + package struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. /// /// - Parameters: /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. - package init(wrapping client: GRPCCore.GRPCClient) { + package init(wrapping client: GRPCCore.GRPCClient) { self.client = client } diff --git a/Sources/GRPCHealthService/HealthService.swift b/Sources/GRPCHealthService/HealthService.swift index 1cf1468..988c227 100644 --- a/Sources/GRPCHealthService/HealthService.swift +++ b/Sources/GRPCHealthService/HealthService.swift @@ -55,7 +55,9 @@ public struct HealthService: Sendable, RegistrableRPCService { self.provider = HealthService.Provider(healthService: healthService) } - public func registerMethods(with router: inout RPCRouter) { + public func registerMethods( + with router: inout RPCRouter + ) where Transport: ServerTransport { self.service.registerMethods(with: &router) } } diff --git a/Sources/GRPCInteropTests/Generated/empty.grpc.swift b/Sources/GRPCInteropTests/Generated/empty.grpc.swift new file mode 100644 index 0000000..d68caab --- /dev/null +++ b/Sources/GRPCInteropTests/Generated/empty.grpc.swift @@ -0,0 +1,24 @@ +// Copyright 2015 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the gRPC Swift generator plugin for the protocol buffer compiler. +// Source: src/proto/grpc/testing/empty.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/grpc/grpc-swift + +// This file contained no services. \ No newline at end of file diff --git a/Sources/GRPCInteropTests/Generated/empty_service.grpc.swift b/Sources/GRPCInteropTests/Generated/empty_service.grpc.swift index e7b8433..f5debb6 100644 --- a/Sources/GRPCInteropTests/Generated/empty_service.grpc.swift +++ b/Sources/GRPCInteropTests/Generated/empty_service.grpc.swift @@ -91,7 +91,7 @@ extension Grpc_Testing_EmptyService { // Default implementation of 'registerMethods(with:)'. extension Grpc_Testing_EmptyService.StreamingServiceProtocol { - public func registerMethods(with router: inout GRPCCore.RPCRouter) {} + public func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport {} } // Default implementation of streaming methods from 'StreamingServiceProtocol'. @@ -126,14 +126,14 @@ extension Grpc_Testing_EmptyService { /// > /// > A service that has zero methods. /// > See https://github.com/grpc/grpc/issues/15574 - public struct Client: ClientProtocol { - private let client: GRPCCore.GRPCClient + public struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. /// /// - Parameters: /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. - public init(wrapping client: GRPCCore.GRPCClient) { + public init(wrapping client: GRPCCore.GRPCClient) { self.client = client } } diff --git a/Sources/GRPCInteropTests/Generated/messages.grpc.swift b/Sources/GRPCInteropTests/Generated/messages.grpc.swift new file mode 100644 index 0000000..125f997 --- /dev/null +++ b/Sources/GRPCInteropTests/Generated/messages.grpc.swift @@ -0,0 +1,26 @@ +// Copyright 2015-2016 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Message definitions to be used by integration test service definitions. + +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the gRPC Swift generator plugin for the protocol buffer compiler. +// Source: src/proto/grpc/testing/messages.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/grpc/grpc-swift + +// This file contained no services. \ No newline at end of file diff --git a/Sources/GRPCInteropTests/Generated/test.grpc.swift b/Sources/GRPCInteropTests/Generated/test.grpc.swift index 94e7a32..b432a9a 100644 --- a/Sources/GRPCInteropTests/Generated/test.grpc.swift +++ b/Sources/GRPCInteropTests/Generated/test.grpc.swift @@ -664,7 +664,7 @@ extension Grpc_Testing_TestService { // Default implementation of 'registerMethods(with:)'. extension Grpc_Testing_TestService.StreamingServiceProtocol { - public func registerMethods(with router: inout GRPCCore.RPCRouter) { + public func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport { router.registerHandler( forMethod: Grpc_Testing_TestService.Method.EmptyCall.descriptor, deserializer: GRPCProtobuf.ProtobufDeserializer(), @@ -1162,14 +1162,14 @@ extension Grpc_Testing_TestService { /// > /// > A simple service to test the various types of RPCs and experiment with /// > performance with various types of payload. - public struct Client: ClientProtocol { - private let client: GRPCCore.GRPCClient + public struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. /// /// - Parameters: /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. - public init(wrapping client: GRPCCore.GRPCClient) { + public init(wrapping client: GRPCCore.GRPCClient) { self.client = client } @@ -2099,7 +2099,7 @@ extension Grpc_Testing_UnimplementedService { // Default implementation of 'registerMethods(with:)'. extension Grpc_Testing_UnimplementedService.StreamingServiceProtocol { - public func registerMethods(with router: inout GRPCCore.RPCRouter) { + public func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport { router.registerHandler( forMethod: Grpc_Testing_UnimplementedService.Method.UnimplementedCall.descriptor, deserializer: GRPCProtobuf.ProtobufDeserializer(), @@ -2191,14 +2191,14 @@ extension Grpc_Testing_UnimplementedService { /// > /// > A simple service NOT implemented at servers so clients can test for /// > that case. - public struct Client: ClientProtocol { - private let client: GRPCCore.GRPCClient + public struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. /// /// - Parameters: /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. - public init(wrapping client: GRPCCore.GRPCClient) { + public init(wrapping client: GRPCCore.GRPCClient) { self.client = client } @@ -2481,7 +2481,7 @@ extension Grpc_Testing_ReconnectService { // Default implementation of 'registerMethods(with:)'. extension Grpc_Testing_ReconnectService.StreamingServiceProtocol { - public func registerMethods(with router: inout GRPCCore.RPCRouter) { + public func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport { router.registerHandler( forMethod: Grpc_Testing_ReconnectService.Method.Start.descriptor, deserializer: GRPCProtobuf.ProtobufDeserializer(), @@ -2621,14 +2621,14 @@ extension Grpc_Testing_ReconnectService { /// > Source IDL Documentation: /// > /// > A service used to control reconnect server. - public struct Client: ClientProtocol { - private let client: GRPCCore.GRPCClient + public struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. /// /// - Parameters: /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. - public init(wrapping client: GRPCCore.GRPCClient) { + public init(wrapping client: GRPCCore.GRPCClient) { self.client = client } diff --git a/Sources/GRPCInteropTests/InteroperabilityTestCase.swift b/Sources/GRPCInteropTests/InteroperabilityTestCase.swift index 1dc379c..07991eb 100644 --- a/Sources/GRPCInteropTests/InteroperabilityTestCase.swift +++ b/Sources/GRPCInteropTests/InteroperabilityTestCase.swift @@ -23,7 +23,7 @@ public protocol InteroperabilityTest { /// /// - Parameter client: The client to use for the test. /// - Throws: Any exception may be thrown to indicate an unsuccessful test. - func run(client: GRPCClient) async throws + func run(client: GRPCClient) async throws } /// Test cases as listed by the [gRPC interoperability test description specification] diff --git a/Sources/GRPCInteropTests/InteroperabilityTestCases.swift b/Sources/GRPCInteropTests/InteroperabilityTestCases.swift index f143791..150da29 100644 --- a/Sources/GRPCInteropTests/InteroperabilityTestCases.swift +++ b/Sources/GRPCInteropTests/InteroperabilityTestCases.swift @@ -37,7 +37,7 @@ private import struct Foundation.Data /// - call was successful /// - response is non-null struct EmptyUnary: InteroperabilityTest { - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) try await testServiceClient.emptyCall( request: ClientRequest(message: Grpc_Testing_Empty()) @@ -70,7 +70,7 @@ struct EmptyUnary: InteroperabilityTest { /// - clients are free to assert that the response payload body contents are zero and comparing /// the entire response message against a golden response struct LargeUnary: InteroperabilityTest { - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) let request = Grpc_Testing_SimpleRequest.with { request in request.responseSize = 314_159 @@ -145,7 +145,7 @@ struct LargeUnary: InteroperabilityTest { /// - Clients are free to assert that the response payload body contents are zeros and comparing the /// entire response message against a golden response. class ClientCompressedUnary: InteroperabilityTest { - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) let compressedRequest = Grpc_Testing_SimpleRequest.with { request in request.expectCompressed = .with { $0.value = true } @@ -253,7 +253,7 @@ class ClientCompressedUnary: InteroperabilityTest { /// - clients are free to assert that the response payload body contents are zero and comparing the /// entire response message against a golden response class ServerCompressedUnary: InteroperabilityTest { - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) let compressedRequest = Grpc_Testing_SimpleRequest.with { request in @@ -342,7 +342,7 @@ class ServerCompressedUnary: InteroperabilityTest { /// - call was successful /// - response aggregated_payload_size is 74922 struct ClientStreaming: InteroperabilityTest { - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) let request = StreamingClientRequest { writer in for bytes in [27182, 8, 1828, 45904] { @@ -392,7 +392,7 @@ struct ClientStreaming: InteroperabilityTest { /// - clients are free to assert that the response payload body contents are zero and /// comparing the entire response messages against golden responses struct ServerStreaming: InteroperabilityTest { - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) let responseSizes = [31415, 9, 2653, 58979] let request = Grpc_Testing_StreamingOutputCallRequest.with { request in @@ -467,7 +467,7 @@ struct ServerStreaming: InteroperabilityTest { /// - clients are free to assert that the response payload body contents are zero and comparing the /// entire response messages against golden responses class ServerCompressedStreaming: InteroperabilityTest { - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) let request: Grpc_Testing_StreamingOutputCallRequest = .with { request in request.responseParameters = [ @@ -579,7 +579,7 @@ class ServerCompressedStreaming: InteroperabilityTest { /// - clients are free to assert that the response payload body contents are zero and /// comparing the entire response messages against golden responses struct PingPong: InteroperabilityTest { - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) let ids = AsyncStream.makeStream(of: Int.self) @@ -645,7 +645,7 @@ struct PingPong: InteroperabilityTest { /// - call was successful /// - exactly zero responses struct EmptyStream: InteroperabilityTest { - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) let request = StreamingClientRequest { _ in } @@ -716,7 +716,7 @@ struct CustomMetadata: InteroperabilityTest { try assertEqual(Array(values), [.binary(self.trailingMetadataValue)]) } - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) let unaryRequest = Grpc_Testing_SimpleRequest.with { request in @@ -823,7 +823,7 @@ struct StatusCodeAndMessage: InteroperabilityTest { let expectedCode = 2 let expectedMessage = "test status message" - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) let message = Grpc_Testing_SimpleRequest.with { @@ -897,7 +897,7 @@ struct StatusCodeAndMessage: InteroperabilityTest { /// - received status message is the same as the sent message for Procedure step 1, including all /// whitespace characters struct SpecialStatusMessage: InteroperabilityTest { - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) let responseMessage = "\t\ntest with whitespace\r\nand Unicode BMP ☺ and non-BMP 😈\t\n" @@ -939,7 +939,7 @@ struct SpecialStatusMessage: InteroperabilityTest { /// Client asserts: /// - received status code is 12 (UNIMPLEMENTED) struct UnimplementedMethod: InteroperabilityTest { - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client) try await testServiceClient.unimplementedCall( request: ClientRequest(message: Grpc_Testing_Empty()) @@ -971,7 +971,7 @@ struct UnimplementedMethod: InteroperabilityTest { /// Client asserts: /// - received status code is 12 (UNIMPLEMENTED) struct UnimplementedService: InteroperabilityTest { - func run(client: GRPCClient) async throws { + func run(client: GRPCClient) async throws { let unimplementedServiceClient = Grpc_Testing_UnimplementedService.Client(wrapping: client) try await unimplementedServiceClient.unimplementedCall( request: ClientRequest(message: Grpc_Testing_Empty()) diff --git a/Sources/GRPCReflectionService/Generated/reflection.grpc.swift b/Sources/GRPCReflectionService/Generated/reflection.grpc.swift index cfa79c9..ed00bce 100644 --- a/Sources/GRPCReflectionService/Generated/reflection.grpc.swift +++ b/Sources/GRPCReflectionService/Generated/reflection.grpc.swift @@ -155,7 +155,7 @@ extension Grpc_Reflection_V1_ServerReflection { // Default implementation of 'registerMethods(with:)'. extension Grpc_Reflection_V1_ServerReflection.StreamingServiceProtocol { - package func registerMethods(with router: inout GRPCCore.RPCRouter) { + package func registerMethods(with router: inout GRPCCore.RPCRouter) where Transport: GRPCCore.ServerTransport { router.registerHandler( forMethod: Grpc_Reflection_V1_ServerReflection.Method.ServerReflectionInfo.descriptor, deserializer: GRPCProtobuf.ProtobufDeserializer(), @@ -232,14 +232,14 @@ extension Grpc_Reflection_V1_ServerReflection { /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived /// means of communication with the remote peer. - package struct Client: ClientProtocol { - private let client: GRPCCore.GRPCClient + package struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. /// /// - Parameters: /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. - package init(wrapping client: GRPCCore.GRPCClient) { + package init(wrapping client: GRPCCore.GRPCClient) { self.client = client } diff --git a/Sources/GRPCReflectionService/Service/ReflectionService.swift b/Sources/GRPCReflectionService/Service/ReflectionService.swift index cb77a0b..7abdadc 100644 --- a/Sources/GRPCReflectionService/Service/ReflectionService.swift +++ b/Sources/GRPCReflectionService/Service/ReflectionService.swift @@ -68,7 +68,9 @@ public struct ReflectionService: Sendable { } extension ReflectionService: RegistrableRPCService { - public func registerMethods(with router: inout RPCRouter) { + public func registerMethods( + with router: inout RPCRouter + ) where Transport: ServerTransport { self.service.registerMethods(with: &router) } } diff --git a/Tests/GRPCHealthServiceTests/HealthTests.swift b/Tests/GRPCHealthServiceTests/HealthTests.swift index 8571557..e43e944 100644 --- a/Tests/GRPCHealthServiceTests/HealthTests.swift +++ b/Tests/GRPCHealthServiceTests/HealthTests.swift @@ -22,7 +22,10 @@ import XCTest final class HealthTests: XCTestCase { private func withHealthClient( - _ body: @Sendable (Grpc_Health_V1_Health.Client, HealthService.Provider) async throws -> Void + _ body: @Sendable ( + Grpc_Health_V1_Health.Client, + Health.Provider + ) async throws -> Void ) async throws { let health = HealthService() let inProcess = InProcessTransport() diff --git a/Tests/GRPCReflectionServiceTests/ReflectionClient.swift b/Tests/GRPCReflectionServiceTests/ReflectionClient.swift index cbfad68..d5be6ec 100644 --- a/Tests/GRPCReflectionServiceTests/ReflectionClient.swift +++ b/Tests/GRPCReflectionServiceTests/ReflectionClient.swift @@ -15,14 +15,15 @@ */ import GRPCCore +import GRPCInProcessTransport import GRPCReflectionService import SwiftProtobuf struct ReflectionClient: Sendable { private typealias Request = Grpc_Reflection_V1_ServerReflectionRequest - private let stub: Grpc_Reflection_V1_ServerReflection.Client + private let stub: Grpc_Reflection_V1_ServerReflection.Client - init(wrapping client: GRPCClient) { + init(wrapping client: GRPCClient) { self.stub = Grpc_Reflection_V1_ServerReflection.Client(wrapping: client) } From 98c3031c936605d4214086e464bf6ca4345fe2f5 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Fri, 17 Jan 2025 12:58:18 +0000 Subject: [PATCH 2/3] update tests --- .../TracingInterceptorTests.swift | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Tests/GRPCInterceptorsTests/TracingInterceptorTests.swift b/Tests/GRPCInterceptorsTests/TracingInterceptorTests.swift index 009f046..cf847ca 100644 --- a/Tests/GRPCInterceptorsTests/TracingInterceptorTests.swift +++ b/Tests/GRPCInterceptorsTests/TracingInterceptorTests.swift @@ -45,7 +45,7 @@ final class TracingInterceptorTests: XCTestCase { try await writer.write(contentsOf: ["request1"]) try await writer.write(contentsOf: ["request2"]) }), - context: .init(descriptor: methodDescriptor) + context: ClientContext(descriptor: methodDescriptor, remotePeer: "", localPeer: "") ) { stream, _ in // Assert the metadata contains the injected context key-value. XCTAssertEqual(stream.metadata, ["trace-id": "\(traceIDString)"]) @@ -113,7 +113,7 @@ final class TracingInterceptorTests: XCTestCase { try await writer.write(contentsOf: ["request1"]) try await writer.write(contentsOf: ["request2"]) }), - context: .init(descriptor: methodDescriptor) + context: ClientContext(descriptor: methodDescriptor, remotePeer: "", localPeer: "") ) { stream, _ in // Assert the metadata contains the injected context key-value. XCTAssertEqual(stream.metadata, ["trace-id": "\(traceIDString)"]) @@ -181,7 +181,12 @@ final class TracingInterceptorTests: XCTestCase { let single = ServerRequest(metadata: ["trace-id": "some-trace-id"], message: [UInt8]()) let response = try await interceptor.intercept( request: .init(single: single), - context: .init(descriptor: methodDescriptor, peer: "", cancellation: .init()) + context: ServerContext( + descriptor: methodDescriptor, + remotePeer: "", + localPeer: "", + cancellation: .init() + ) ) { _, _ in StreamingServerResponse(error: .init(code: .unknown, message: "Test error")) } @@ -210,7 +215,12 @@ final class TracingInterceptorTests: XCTestCase { let single = ServerRequest(metadata: ["trace-id": "some-trace-id"], message: [UInt8]()) let response = try await interceptor.intercept( request: .init(single: single), - context: .init(descriptor: methodDescriptor, peer: "", cancellation: .init()) + context: ServerContext( + descriptor: methodDescriptor, + remotePeer: "", + localPeer: "", + cancellation: .init() + ) ) { _, _ in { [serviceContext = ServiceContext.current] in return StreamingServerResponse( @@ -275,7 +285,12 @@ final class TracingInterceptorTests: XCTestCase { let single = ServerRequest(metadata: ["trace-id": "some-trace-id"], message: [UInt8]()) let response = try await interceptor.intercept( request: .init(single: single), - context: .init(descriptor: methodDescriptor, peer: "", cancellation: .init()) + context: ServerContext( + descriptor: methodDescriptor, + remotePeer: "", + localPeer: "", + cancellation: .init() + ) ) { _, _ in { [serviceContext = ServiceContext.current] in return StreamingServerResponse( From 02cda3918b709f9b40018c7de005fa45fe893558 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Fri, 17 Jan 2025 13:01:54 +0000 Subject: [PATCH 3/3] fix tests --- Tests/GRPCHealthServiceTests/HealthTests.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/GRPCHealthServiceTests/HealthTests.swift b/Tests/GRPCHealthServiceTests/HealthTests.swift index e43e944..7f53656 100644 --- a/Tests/GRPCHealthServiceTests/HealthTests.swift +++ b/Tests/GRPCHealthServiceTests/HealthTests.swift @@ -24,7 +24,7 @@ final class HealthTests: XCTestCase { private func withHealthClient( _ body: @Sendable ( Grpc_Health_V1_Health.Client, - Health.Provider + HealthService.Provider ) async throws -> Void ) async throws { let health = HealthService() @@ -39,7 +39,7 @@ final class HealthTests: XCTestCase { } group.addTask { - try await client.run() + try await client.runConnections() } do {