diff --git a/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt b/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt index 7eb985229..4e9246732 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt @@ -84,14 +84,17 @@ class ClientTest { assert(!cannotMessage) } @Test - @Ignore("CI Issues") fun testPublicCanMessage() { - val fixtures = fixtures() + val aliceWallet = PrivateKeyBuilder() val notOnNetwork = PrivateKeyBuilder() - val clientOptions = - ClientOptions(api = ClientOptions.Api(env = XMTPEnvironment.LOCAL, isSecure = false, appVersion = "XMTPTest/v1.0.0")) - val canMessage = Client.canMessage(fixtures.bobClient.address, clientOptions) - val cannotMessage = Client.canMessage(notOnNetwork.address, clientOptions) + val identity = PrivateKeyBuilder().getPrivateKey() + val authorized = aliceWallet.createIdentity(identity) + val authToken = authorized.createAuthToken() + val api = GRPCApiClient(environment = XMTPEnvironment.DEV, secure = false) + api.setAuthToken(authToken) + + val canMessage = Client.canMessage(aliceWallet.address, apiClient = api) + val cannotMessage = Client.canMessage(notOnNetwork.address, apiClient = api) assert(canMessage) assert(!cannotMessage) } diff --git a/library/src/main/java/org/xmtp/android/library/Client.kt b/library/src/main/java/org/xmtp/android/library/Client.kt index a17afd248..a674c568e 100644 --- a/library/src/main/java/org/xmtp/android/library/Client.kt +++ b/library/src/main/java/org/xmtp/android/library/Client.kt @@ -114,10 +114,10 @@ class Client() { ) ) } - fun canMessage(peerAddress: String, options: ClientOptions? = null): Boolean { + fun canMessage(peerAddress: String, options: ClientOptions? = null, apiClient: GRPCApiClient? = null): Boolean { val clientOptions = options ?: ClientOptions() - val apiClient = GRPCApiClient(environment = clientOptions.api.env, secure = clientOptions.api.isSecure) - return runBlocking { apiClient.queryTopic(Topic.contact(peerAddress)).envelopesList.size > 0 } + val api = apiClient ?: GRPCApiClient(environment = clientOptions.api.env, secure = clientOptions.api.isSecure) + return runBlocking { api.queryTopic(Topic.contact(peerAddress)).envelopesList.size > 0 } } }