From 6393110b2ad50d0c2bc52055a0fa6fbd54972b60 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 29 Nov 2023 10:46:43 -0800 Subject: [PATCH] fix up spacing issues --- Sources/XMTP/Client.swift | 22 +++++++++++----------- Tests/XMTPTests/ClientTests.swift | 28 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Sources/XMTP/Client.swift b/Sources/XMTP/Client.swift index 2461a8a0..ebcd0cd7 100644 --- a/Sources/XMTP/Client.swift +++ b/Sources/XMTP/Client.swift @@ -193,17 +193,17 @@ public final class Client: Sendable { return try await query(topic: .contact(peerAddress)).envelopes.count > 0 } - public static func canMessage(_ peerAddress: String, options: ClientOptions? = nil) async throws -> Bool { - let options = options ?? ClientOptions() - - let client = try await XMTPRust.create_client(GRPCApiClient.envToUrl(env: options.api.env), options.api.env != .local) - let apiClient = try GRPCApiClient( - environment: options.api.env, - secure: options.api.isSecure, - rustClient: client - ) - return try await apiClient.query(topic: .contact(peerAddress)).envelopes.count > 0 - } + public static func canMessage(_ peerAddress: String, options: ClientOptions? = nil) async throws -> Bool { + let options = options ?? ClientOptions() + + let client = try await XMTPRust.create_client(GRPCApiClient.envToUrl(env: options.api.env), options.api.env != .local) + let apiClient = try GRPCApiClient( + environment: options.api.env, + secure: options.api.isSecure, + rustClient: client + ) + return try await apiClient.query(topic: .contact(peerAddress)).envelopes.count > 0 + } public func importConversation(from conversationData: Data) throws -> Conversation? { let jsonDecoder = JSONDecoder() diff --git a/Tests/XMTPTests/ClientTests.swift b/Tests/XMTPTests/ClientTests.swift index efb6e4a9..7a156c82 100644 --- a/Tests/XMTPTests/ClientTests.swift +++ b/Tests/XMTPTests/ClientTests.swift @@ -30,20 +30,20 @@ class ClientTests: XCTestCase { XCTAssertFalse(cannotMessage) } - func testStaticCanMessage() async throws { - try TestConfig.skip(because: "run manually against dev") - let opts = ClientOptions(api: ClientOptions.Api(env: .local, isSecure: false)) - - let aliceWallet = try PrivateKey.generate() - let notOnNetwork = try PrivateKey.generate() - let alice = try await Client.create(account: aliceWallet, options: opts) - - let canMessage = try await Client.canMessage(alice.address, options: opts) - let cannotMessage = try await Client.canMessage(notOnNetwork.address, options: opts) - XCTAssertTrue(canMessage) - XCTAssertFalse(cannotMessage) - } - + func testStaticCanMessage() async throws { + try TestConfig.skip(because: "run manually against local") + let opts = ClientOptions(api: ClientOptions.Api(env: .local, isSecure: false)) + + let aliceWallet = try PrivateKey.generate() + let notOnNetwork = try PrivateKey.generate() + let alice = try await Client.create(account: aliceWallet, options: opts) + + let canMessage = try await Client.canMessage(alice.address, options: opts) + let cannotMessage = try await Client.canMessage(notOnNetwork.address, options: opts) + XCTAssertTrue(canMessage) + XCTAssertFalse(cannotMessage) + } + func testHasPrivateKeyBundleV1() async throws { let fakeWallet = try PrivateKey.generate() let client = try await Client.create(account: fakeWallet, apiClient: FakeApiClient())