Skip to content

Commit

Permalink
fix up the unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Oct 25, 2023
1 parent d1f33d1 commit 0d85fe6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package org.xmtp.android.library

import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Assert.assertEquals
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

@RunWith(AndroidJUnit4::class)
class ClientTest {
@Test
fun testTakesAWallet() {
Expand All @@ -20,6 +26,20 @@ class ClientTest {
assert(preKey?.publicKey?.hasSignature() ?: false)
}

@Test
fun testSerialization() {
val wallet = PrivateKeyBuilder()
val v1 =
PrivateKeyOuterClass.PrivateKeyBundleV1.newBuilder().build().generate(wallet = wallet)
val encodedData = PrivateKeyBundleV1Builder.encodeData(v1)
val v1Copy = PrivateKeyBundleV1Builder.fromEncodedData(encodedData)
val client = Client().buildFrom(v1Copy)
assertEquals(
wallet.address,
client.address
)
}

@Test
fun testCanBeCreatedWithBundle() {
val fakeWallet = PrivateKeyBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,6 @@ class PrivateKeyBundleTest {
)
}

@Test
fun testSerialization() {
val wallet = PrivateKeyBuilder()
val v1 =
PrivateKeyOuterClass.PrivateKeyBundleV1.newBuilder().build().generate(wallet = wallet)
val encodedData = PrivateKeyBundleV1Builder.encodeData(v1)
val v1Copy = PrivateKeyBundleV1Builder.fromEncodedData(encodedData)
val client = Client().buildFrom(v1Copy)
assertEquals(
wallet.address,
client.address
)
}

@Test
fun testKeyBundlesAreSigned() {
val wallet = PrivateKeyBuilder()
Expand Down

0 comments on commit 0d85fe6

Please sign in to comment.