Skip to content

Commit

Permalink
fix up spacing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Nov 29, 2023
1 parent 8009db6 commit 6393110
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
22 changes: 11 additions & 11 deletions Sources/XMTP/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
28 changes: 14 additions & 14 deletions Tests/XMTPTests/ClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 6393110

Please sign in to comment.