@@ -9,6 +9,7 @@ import org.junit.Assert.fail
9
9
import org.junit.Test
10
10
import org.junit.runner.RunWith
11
11
import org.xmtp.android.library.messages.PrivateKeyBuilder
12
+ import org.xmtp.android.library.messages.rawData
12
13
import org.xmtp.android.library.messages.walletAddress
13
14
import uniffi.xmtpv3.GenericException
14
15
import java.io.File
@@ -29,15 +30,15 @@ class ClientTest {
29
30
dbEncryptionKey = key
30
31
)
31
32
val client = runBlocking {
32
- Client () .create(account = fakeWallet, options = options)
33
+ Client .create(account = fakeWallet, options = options)
33
34
}
34
35
35
36
runBlocking {
36
37
client.canMessage(listOf (client.address))[client.address]?.let { assert (it) }
37
38
}
38
39
39
40
val fromBundle = runBlocking {
40
- Client () .build(fakeWallet.address, options = options)
41
+ Client .build(fakeWallet.address, options = options)
41
42
}
42
43
assertEquals(client.address, fromBundle.address)
43
44
assertEquals(client.inboxId, fromBundle.inboxId)
@@ -59,7 +60,7 @@ class ClientTest {
59
60
)
60
61
val inboxId = runBlocking { Client .getOrCreateInboxId(options.api, fakeWallet.address) }
61
62
val client = runBlocking {
62
- Client () .create(
63
+ Client .create(
63
64
account = fakeWallet,
64
65
options = options
65
66
)
@@ -126,7 +127,7 @@ class ClientTest {
126
127
val fakeWallet = PrivateKeyBuilder ()
127
128
val fakeWallet2 = PrivateKeyBuilder ()
128
129
var client = runBlocking {
129
- Client () .create(
130
+ Client .create(
130
131
account = fakeWallet,
131
132
options = ClientOptions (
132
133
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -136,7 +137,7 @@ class ClientTest {
136
137
)
137
138
}
138
139
val client2 = runBlocking {
139
- Client () .create(
140
+ Client .create(
140
141
account = fakeWallet2,
141
142
options = ClientOptions (
142
143
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -156,7 +157,7 @@ class ClientTest {
156
157
client.deleteLocalDatabase()
157
158
158
159
client = runBlocking {
159
- Client () .create(
160
+ Client .create(
160
161
account = fakeWallet,
161
162
options = ClientOptions (
162
163
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -177,7 +178,7 @@ class ClientTest {
177
178
val context = InstrumentationRegistry .getInstrumentation().targetContext
178
179
val fakeWallet = PrivateKeyBuilder ()
179
180
val client = runBlocking {
180
- Client () .create(
181
+ Client .create(
181
182
account = fakeWallet,
182
183
options = ClientOptions (
183
184
ClientOptions .Api (XMTPEnvironment .DEV , true ),
@@ -197,7 +198,7 @@ class ClientTest {
197
198
val context = InstrumentationRegistry .getInstrumentation().targetContext
198
199
val fakeWallet = PrivateKeyBuilder ()
199
200
val client = runBlocking {
200
- Client () .create(
201
+ Client .create(
201
202
account = fakeWallet,
202
203
options = ClientOptions (
203
204
ClientOptions .Api (XMTPEnvironment .PRODUCTION , true ),
@@ -230,7 +231,7 @@ class ClientTest {
230
231
)
231
232
232
233
try {
233
- runBlocking { Client () .create(account = fakeWallet, options = opts) }
234
+ runBlocking { Client .create(account = fakeWallet, options = opts) }
234
235
expectation.get(5 , TimeUnit .SECONDS )
235
236
} catch (e: Exception ) {
236
237
fail(" Error: $e " )
@@ -244,7 +245,7 @@ class ClientTest {
244
245
val fakeWallet = PrivateKeyBuilder ()
245
246
val fakeWallet2 = PrivateKeyBuilder ()
246
247
val boClient = runBlocking {
247
- Client () .create(
248
+ Client .create(
248
249
account = fakeWallet,
249
250
options = ClientOptions (
250
251
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -254,7 +255,7 @@ class ClientTest {
254
255
)
255
256
}
256
257
val alixClient = runBlocking {
257
- Client () .create(
258
+ Client .create(
258
259
account = fakeWallet2,
259
260
options = ClientOptions (
260
261
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -294,7 +295,7 @@ class ClientTest {
294
295
val alixWallet = PrivateKeyBuilder ()
295
296
val boWallet = PrivateKeyBuilder ()
296
297
val alixClient = runBlocking {
297
- Client () .create(
298
+ Client .create(
298
299
account = alixWallet,
299
300
options = ClientOptions (
300
301
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -304,7 +305,7 @@ class ClientTest {
304
305
)
305
306
}
306
307
val boClient = runBlocking {
307
- Client () .create(
308
+ Client .create(
308
309
account = boWallet,
309
310
options = ClientOptions (
310
311
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -326,7 +327,7 @@ class ClientTest {
326
327
val alixWallet = PrivateKeyBuilder ()
327
328
328
329
val alixClient = runBlocking {
329
- Client () .create(
330
+ Client .create(
330
331
account = alixWallet,
331
332
options = ClientOptions (
332
333
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -337,7 +338,7 @@ class ClientTest {
337
338
}
338
339
339
340
val alixClient2 = runBlocking {
340
- Client () .create(
341
+ Client .create(
341
342
account = alixWallet,
342
343
options = ClientOptions (
343
344
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -349,7 +350,7 @@ class ClientTest {
349
350
}
350
351
351
352
val alixClient3 = runBlocking {
352
- Client () .create(
353
+ Client .create(
353
354
account = alixWallet,
354
355
options = ClientOptions (
355
356
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -378,7 +379,7 @@ class ClientTest {
378
379
val context = InstrumentationRegistry .getInstrumentation().targetContext
379
380
val alixWallet = PrivateKeyBuilder ()
380
381
runBlocking {
381
- val alixClient = Client () .create(
382
+ val alixClient = Client .create(
382
383
account = alixWallet,
383
384
options = ClientOptions (
384
385
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -387,7 +388,7 @@ class ClientTest {
387
388
)
388
389
)
389
390
390
- val alixClient2 = Client () .create(
391
+ val alixClient2 = Client .create(
391
392
account = alixWallet,
392
393
options = ClientOptions (
393
394
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -399,7 +400,7 @@ class ClientTest {
399
400
}
400
401
401
402
val alixClient3 = runBlocking {
402
- Client () .create(
403
+ Client .create(
403
404
account = alixWallet,
404
405
options = ClientOptions (
405
406
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -487,7 +488,7 @@ class ClientTest {
487
488
val key = SecureRandom ().generateSeed(32 )
488
489
val context = InstrumentationRegistry .getInstrumentation().targetContext
489
490
val alixClient2 = runBlocking {
490
- Client () .create(
491
+ Client .create(
491
492
account = fixtures.alixAccount,
492
493
options = ClientOptions (
493
494
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -610,7 +611,7 @@ class ClientTest {
610
611
val alixWallet = PrivateKeyBuilder ()
611
612
612
613
val alixClient = runBlocking {
613
- Client () .create(
614
+ Client .create(
614
615
account = alixWallet,
615
616
options = ClientOptions (
616
617
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -625,7 +626,7 @@ class ClientTest {
625
626
XMTPException ::class .java
626
627
) {
627
628
runBlocking {
628
- Client () .build(
629
+ Client .build(
629
630
address = alixClient.address,
630
631
options = ClientOptions (
631
632
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -641,7 +642,7 @@ class ClientTest {
641
642
XMTPException ::class .java
642
643
) {
643
644
runBlocking {
644
- Client () .create(
645
+ Client .create(
645
646
account = alixWallet,
646
647
options = ClientOptions (
647
648
ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
@@ -652,4 +653,32 @@ class ClientTest {
652
653
}
653
654
}
654
655
}
656
+
657
+ @Test
658
+ fun testCreatesAClientManually () {
659
+ val key = SecureRandom ().generateSeed(32 )
660
+ val context = InstrumentationRegistry .getInstrumentation().targetContext
661
+ val fakeWallet = PrivateKeyBuilder ()
662
+ val options = ClientOptions (
663
+ ClientOptions .Api (XMTPEnvironment .LOCAL , false ),
664
+ appContext = context,
665
+ dbEncryptionKey = key
666
+ )
667
+ val inboxId = runBlocking { Client .getOrCreateInboxId(options.api, fakeWallet.address) }
668
+ val client = runBlocking {
669
+ Client .ffiCreateClient(fakeWallet.address, options)
670
+ }
671
+ runBlocking {
672
+ val sigRequest = client.ffiSignatureRequest()
673
+ sigRequest?.let { signatureRequest ->
674
+ signatureRequest.addEcdsaSignature(fakeWallet.sign(signatureRequest.signatureText()).rawData)
675
+ client.ffiRegisterIdentity(signatureRequest)
676
+ }
677
+ }
678
+ runBlocking {
679
+ client.canMessage(listOf (client.address))[client.address]?.let { assert (it) }
680
+ }
681
+ assert (client.installationId.isNotEmpty())
682
+ assertEquals(inboxId, client.inboxId)
683
+ }
655
684
}
0 commit comments