Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kele-leanes committed Dec 5, 2023
1 parent 53a3137 commit 81a8a7e
Showing 1 changed file with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package org.xmtp.android.library

import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Assert.assertEquals
import org.junit.Assert.fail
import org.junit.Test
import org.junit.runner.RunWith
import org.xmtp.android.library.messages.PrivateKeyBuilder
import org.xmtp.android.library.messages.PrivateKeyBundleV1Builder
import org.xmtp.android.library.messages.generate
import org.xmtp.proto.message.contents.PrivateKeyOuterClass
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeUnit

@RunWith(AndroidJUnit4::class)
class ClientTest {
Expand Down Expand Up @@ -98,4 +101,48 @@ class ClientTest {
assert(canMessage)
assert(!cannotMessage)
}

@Test
fun testPreEnableIdentityCallback() {
val fakeWallet = PrivateKeyBuilder()
val expectation = CompletableFuture<Unit>()

val preEnableIdentityCallback: suspend () -> Unit = {
println("preEnableIdentityCallback called")
expectation.complete(Unit)
}

val opts = ClientOptions(ClientOptions.Api(XMTPEnvironment.LOCAL, false),
preEnableIdentityCallback = preEnableIdentityCallback
)

try {
Client().create(account = fakeWallet, options = opts)
expectation.get(5, TimeUnit.SECONDS)
} catch (e: Exception) {
fail("Error: $e")
}
}

@Test
fun testPreCreateIdentityCallback() {
val fakeWallet = PrivateKeyBuilder()
val expectation = CompletableFuture<Unit>()

val preCreateIdentityCallback: suspend () -> Unit = {
println("preCreateIdentityCallback called")
expectation.complete(Unit)
}

val opts = ClientOptions(ClientOptions.Api(XMTPEnvironment.LOCAL, false),
preCreateIdentityCallback = preCreateIdentityCallback
)

try {
Client().create(account = fakeWallet, options = opts)
expectation.get(5, TimeUnit.SECONDS)
} catch (e: Exception) {
fail("Error: $e")
}
}
}

0 comments on commit 81a8a7e

Please sign in to comment.