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 6d89385c8..2e6e82f54 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt @@ -126,21 +126,24 @@ class ClientTest { val key = SecureRandom().generateSeed(32) val context = InstrumentationRegistry.getInstrumentation().targetContext val fakeWallet = PrivateKeyBuilder() + val options = ClientOptions( + ClientOptions.Api(XMTPEnvironment.LOCAL, false), + enableV3 = true, + appContext = context, + dbEncryptionKey = key + ) + val inboxId = runBlocking { Client.getOrCreateInboxId(options, fakeWallet.address) } val client = runBlocking { Client().create( account = fakeWallet, - options = ClientOptions( - ClientOptions.Api(XMTPEnvironment.LOCAL, false), - enableV3 = true, - appContext = context, - dbEncryptionKey = key - ) + options = options ) } runBlocking { client.canMessageV3(listOf(client.address))[client.address]?.let { assert(it) } } assert(client.installationId.isNotEmpty()) + assertEquals(inboxId, client.inboxId) } @Test @@ -178,6 +181,7 @@ class ClientTest { assertEquals(client.conversations.listGroups().size, 1) } + assert(client.dbPath.isNotEmpty()) client.deleteLocalDatabase() client = runBlocking { 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 f09d9cb37..275581c3e 100644 --- a/library/src/main/java/org/xmtp/android/library/Client.kt +++ b/library/src/main/java/org/xmtp/android/library/Client.kt @@ -84,7 +84,7 @@ class Client() { val libXMTPVersion: String = getVersionInfo() var installationId: String = "" private var v3Client: FfiXmtpClient? = null - private var dbPath: String = "" + var dbPath: String = "" lateinit var inboxId: String companion object { @@ -96,6 +96,19 @@ class Client() { registry } + suspend fun getOrCreateInboxId(options: ClientOptions, address: String): String { + var inboxId = getInboxIdForAddress( + logger = XMTPLogger(), + host = options.api.env.getUrl(), + isSecure = options.api.isSecure, + accountAddress = address + ) + if (inboxId.isNullOrBlank()) { + inboxId = generateInboxId(address, 0.toULong()) + } + return inboxId + } + fun register(codec: ContentCodec<*>) { codecRegistry.register(codec = codec) } @@ -620,19 +633,6 @@ class Client() { v3Client?.dbReconnect() ?: throw XMTPException("Error no V3 client initialized") } - suspend fun getOrCreateInboxId(options: ClientOptions, address: String): String { - var inboxId = getInboxIdForAddress( - logger = logger, - host = options.api.env.getUrl(), - isSecure = options.api.isSecure, - accountAddress = address - ) - if (inboxId.isNullOrBlank()) { - inboxId = generateInboxId(address, 0.toULong()) - } - return inboxId - } - suspend fun requestMessageHistorySync() { v3Client?.requestHistorySync() ?: throw XMTPException("Error no V3 client initialized") }