From 0d85fe637011612f33bc14ba2760b7dcee3ff8b0 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 25 Oct 2023 16:27:30 -0700 Subject: [PATCH] fix up the unit tests --- .../org/xmtp/android/library/ClientTest.kt | 20 +++++++++++++++++++ .../android/library/PrivateKeyBundleTest.kt | 14 ------------- 2 files changed, 20 insertions(+), 14 deletions(-) rename library/src/{test => androidTest}/java/org/xmtp/android/library/ClientTest.kt (74%) diff --git a/library/src/test/java/org/xmtp/android/library/ClientTest.kt b/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt similarity index 74% rename from library/src/test/java/org/xmtp/android/library/ClientTest.kt rename to library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt index af29c0cc4..c438e48c6 100644 --- a/library/src/test/java/org/xmtp/android/library/ClientTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/ClientTest.kt @@ -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() { @@ -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() diff --git a/library/src/test/java/org/xmtp/android/library/PrivateKeyBundleTest.kt b/library/src/test/java/org/xmtp/android/library/PrivateKeyBundleTest.kt index ca21aba74..47ce41670 100644 --- a/library/src/test/java/org/xmtp/android/library/PrivateKeyBundleTest.kt +++ b/library/src/test/java/org/xmtp/android/library/PrivateKeyBundleTest.kt @@ -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()