|
1 | 1 | package org.xmtp.android.library
|
2 | 2 |
|
3 | 3 | import androidx.test.ext.junit.runners.AndroidJUnit4
|
| 4 | +import androidx.test.platform.app.InstrumentationRegistry |
4 | 5 | import org.junit.Assert.assertEquals
|
| 6 | +import org.junit.Assert.assertNull |
5 | 7 | import org.junit.Assert.fail
|
6 | 8 | import org.junit.Ignore
|
7 | 9 | import org.junit.Test
|
@@ -78,6 +80,60 @@ class ClientTest {
|
78 | 80 | )
|
79 | 81 | }
|
80 | 82 |
|
| 83 | + @Test |
| 84 | + fun testV3CanBeCreatedWithBundle() { |
| 85 | + val context = InstrumentationRegistry.getInstrumentation().targetContext |
| 86 | + val fakeWallet = PrivateKeyBuilder() |
| 87 | + val options = ClientOptions( |
| 88 | + ClientOptions.Api(XMTPEnvironment.LOCAL, false), |
| 89 | + enableAlphaMls = true, |
| 90 | + appContext = context |
| 91 | + ) |
| 92 | + val client = |
| 93 | + Client().create(account = fakeWallet, options = options) |
| 94 | + assertEquals( |
| 95 | + client.address.lowercase(), |
| 96 | + client.libXMTPClient?.accountAddress()?.lowercase() |
| 97 | + ) |
| 98 | + |
| 99 | + val bundle = client.privateKeyBundle |
| 100 | + val clientFromV1Bundle = Client().buildFromBundle(bundle, account = fakeWallet, options = options) |
| 101 | + assertEquals(client.address, clientFromV1Bundle.address) |
| 102 | + assertEquals( |
| 103 | + client.privateKeyBundleV1.identityKey, |
| 104 | + clientFromV1Bundle.privateKeyBundleV1.identityKey, |
| 105 | + ) |
| 106 | + assertEquals( |
| 107 | + client.libXMTPClient?.accountAddress(), |
| 108 | + clientFromV1Bundle.libXMTPClient?.accountAddress() |
| 109 | + ) |
| 110 | + } |
| 111 | + |
| 112 | + @Test |
| 113 | + fun testCreatesAV3Client() { |
| 114 | + val context = InstrumentationRegistry.getInstrumentation().targetContext |
| 115 | + val fakeWallet = PrivateKeyBuilder() |
| 116 | + val client = |
| 117 | + Client().create( |
| 118 | + account = fakeWallet, |
| 119 | + options = ClientOptions( |
| 120 | + ClientOptions.Api(XMTPEnvironment.LOCAL, false), |
| 121 | + enableAlphaMls = true, |
| 122 | + appContext = context |
| 123 | + ) |
| 124 | + ) |
| 125 | + val v3Client = client.libXMTPClient |
| 126 | + assertEquals(client.address.lowercase(), v3Client?.accountAddress()?.lowercase()) |
| 127 | + } |
| 128 | + |
| 129 | + @Test |
| 130 | + fun testDoesNotCreateAV3Client() { |
| 131 | + val fakeWallet = PrivateKeyBuilder() |
| 132 | + val client = Client().create(account = fakeWallet) |
| 133 | + val v3Client = client.libXMTPClient |
| 134 | + assertNull(v3Client) |
| 135 | + } |
| 136 | + |
81 | 137 | @Test
|
82 | 138 | fun testCanMessage() {
|
83 | 139 | val fixtures = fixtures()
|
|
0 commit comments