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 c438e48c6..7eb985229 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt @@ -2,6 +2,7 @@ package org.xmtp.android.library import androidx.test.ext.junit.runners.AndroidJUnit4 import org.junit.Assert.assertEquals +import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.xmtp.android.library.messages.PrivateKeyBuilder @@ -82,4 +83,16 @@ class ClientTest { assert(canMessage) assert(!cannotMessage) } + @Test + @Ignore("CI Issues") + fun testPublicCanMessage() { + val fixtures = fixtures() + 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) + 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 9fa5f7fff..a17afd248 100644 --- a/library/src/main/java/org/xmtp/android/library/Client.kt +++ b/library/src/main/java/org/xmtp/android/library/Client.kt @@ -114,6 +114,11 @@ class Client() { ) ) } + fun canMessage(peerAddress: String, options: ClientOptions? = 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 } + } } constructor(