@@ -5,6 +5,7 @@ import app.cash.turbine.test
5
5
import com.google.protobuf.kotlin.toByteString
6
6
import com.google.protobuf.kotlin.toByteStringUtf8
7
7
import kotlinx.coroutines.ExperimentalCoroutinesApi
8
+ import kotlinx.coroutines.runBlocking
8
9
import org.junit.Assert
9
10
import org.junit.Assert.assertEquals
10
11
import org.junit.Assert.assertFalse
@@ -173,8 +174,8 @@ class ConversationTest {
173
174
val bobConversation = bobClient.conversations.newConversation(aliceWallet.address)
174
175
val aliceConversation = aliceClient.conversations.newConversation(bobWallet.address)
175
176
176
- bobConversation.send(content = " hey alice" )
177
- bobConversation.send(content = " hey alice again" )
177
+ runBlocking { bobConversation.send(content = " hey alice" ) }
178
+ runBlocking { bobConversation.send(content = " hey alice again" ) }
178
179
val messages = aliceConversation.messages()
179
180
assertEquals(2 , messages.size)
180
181
assertEquals(" hey alice" , messages[1 ].body)
@@ -192,7 +193,7 @@ class ConversationTest {
192
193
bobWallet.address,
193
194
InvitationV1ContextBuilder .buildFromConversation(" hi" ),
194
195
)
195
- bobConversation.send(content = " hey alice" )
196
+ runBlocking { bobConversation.send(content = " hey alice" ) }
196
197
val messages = aliceConversation.messages()
197
198
assertEquals(1 , messages.size)
198
199
assertEquals(" hey alice" , messages[0 ].body)
@@ -268,10 +269,10 @@ class ConversationTest {
268
269
fixtures.publishLegacyContact(client = aliceClient)
269
270
val bobConversation = bobClient.conversations.newConversation(aliceWallet.address)
270
271
val aliceConversation = aliceClient.conversations.newConversation(bobWallet.address)
271
- bobConversation.send(
272
+ runBlocking { bobConversation.send(
272
273
text = MutableList (1000 ) { " A" }.toString(),
273
274
sendOptions = SendOptions (compression = EncodedContentCompression .GZIP ),
274
- )
275
+ ) }
275
276
val messages = aliceConversation.messages()
276
277
assertEquals(1 , messages.size)
277
278
assertEquals(MutableList (1000 ) { " A" }.toString(), messages[0 ].content())
@@ -283,10 +284,10 @@ class ConversationTest {
283
284
fixtures.publishLegacyContact(client = aliceClient)
284
285
val bobConversation = bobClient.conversations.newConversation(aliceWallet.address)
285
286
val aliceConversation = aliceClient.conversations.newConversation(bobWallet.address)
286
- bobConversation.send(
287
+ runBlocking { bobConversation.send(
287
288
content = MutableList (1000 ) { " A" }.toString(),
288
289
options = SendOptions (compression = EncodedContentCompression .DEFLATE ),
289
- )
290
+ )}
290
291
val messages = aliceConversation.messages()
291
292
assertEquals(1 , messages.size)
292
293
assertEquals(MutableList (1000 ) { " A" }.toString(), messages[0 ].content())
@@ -302,10 +303,10 @@ class ConversationTest {
302
303
bobWallet.address,
303
304
InvitationV1ContextBuilder .buildFromConversation(conversationId = " hi" ),
304
305
)
305
- bobConversation.send(
306
+ runBlocking { bobConversation.send(
306
307
text = MutableList (1000 ) { " A" }.toString(),
307
308
sendOptions = SendOptions (compression = EncodedContentCompression .GZIP ),
308
- )
309
+ )}
309
310
val messages = aliceConversation.messages()
310
311
assertEquals(1 , messages.size)
311
312
assertEquals(MutableList (1000 ) { " A" }.toString(), messages[0 ].body)
@@ -322,10 +323,10 @@ class ConversationTest {
322
323
bobWallet.address,
323
324
InvitationV1ContextBuilder .buildFromConversation(conversationId = " hi" ),
324
325
)
325
- bobConversation.send(
326
+ runBlocking { bobConversation.send(
326
327
content = MutableList (1000 ) { " A" }.toString(),
327
328
options = SendOptions (compression = EncodedContentCompression .DEFLATE ),
328
- )
329
+ )}
329
330
val messages = aliceConversation.messages()
330
331
assertEquals(1 , messages.size)
331
332
assertEquals(MutableList (1000 ) { " A" }.toString(), messages[0 ].body)
@@ -401,9 +402,9 @@ class ConversationTest {
401
402
402
403
val date = Date ()
403
404
date.time = date.time - 1000000
404
- bobConversation.send(text = " hey alice 1" , sentAt = date)
405
- bobConversation.send(text = " hey alice 2" )
406
- bobConversation.send(text = " hey alice 3" )
405
+ runBlocking { bobConversation.send(text = " hey alice 1" , sentAt = date) }
406
+ runBlocking { bobConversation.send(text = " hey alice 2" ) }
407
+ runBlocking { bobConversation.send(text = " hey alice 3" ) }
407
408
val messages = aliceConversation.messages(limit = 1 )
408
409
assertEquals(1 , messages.size)
409
410
assertEquals(" hey alice 3" , messages[0 ].body)
@@ -422,9 +423,9 @@ class ConversationTest {
422
423
)
423
424
val date = Date ()
424
425
date.time = date.time - 1000000
425
- bobConversation.send(text = " hey alice 1" , sentAt = date)
426
- bobConversation.send(text = " hey alice 2" )
427
- bobConversation.send(text = " hey alice 3" )
426
+ runBlocking { bobConversation.send(text = " hey alice 1" , sentAt = date) }
427
+ runBlocking { bobConversation.send(text = " hey alice 2" ) }
428
+ runBlocking { bobConversation.send(text = " hey alice 3" ) }
428
429
val messages = aliceConversation.messages(limit = 1 )
429
430
assertEquals(1 , messages.size)
430
431
assertEquals(" hey alice 3" , messages[0 ].body)
@@ -445,9 +446,9 @@ class ConversationTest {
445
446
val steveConversation =
446
447
aliceClient.conversations.newConversation(fixtures.caro.walletAddress)
447
448
448
- bobConversation.send(text = " hey alice 1" )
449
- bobConversation.send(text = " hey alice 2" )
450
- steveConversation.send(text = " hey alice 3" )
449
+ runBlocking { bobConversation.send(text = " hey alice 1" ) }
450
+ runBlocking { bobConversation.send(text = " hey alice 2" ) }
451
+ runBlocking { steveConversation.send(text = " hey alice 3" ) }
451
452
val messages = aliceClient.conversations.listBatchMessages(
452
453
listOf (
453
454
Pair (steveConversation.topic, null ),
@@ -469,9 +470,9 @@ class ConversationTest {
469
470
val steveConversation =
470
471
aliceClient.conversations.newConversation(fixtures.caro.walletAddress)
471
472
472
- bobConversation.send(text = " hey alice 1" )
473
- bobConversation.send(text = " hey alice 2" )
474
- steveConversation.send(text = " hey alice 3" )
473
+ runBlocking { bobConversation.send(text = " hey alice 1" ) }
474
+ runBlocking { bobConversation.send(text = " hey alice 2" ) }
475
+ runBlocking { steveConversation.send(text = " hey alice 3" ) }
475
476
val messages = aliceClient.conversations.listBatchDecryptedMessages(
476
477
listOf (
477
478
Pair (steveConversation.topic, null ),
@@ -493,16 +494,16 @@ class ConversationTest {
493
494
val steveConversation =
494
495
aliceClient.conversations.newConversation(fixtures.caro.walletAddress)
495
496
496
- bobConversation.send(text = " hey alice 1 bob" )
497
- steveConversation.send(text = " hey alice 1 steve" )
497
+ runBlocking { bobConversation.send(text = " hey alice 1 bob" ) }
498
+ runBlocking { steveConversation.send(text = " hey alice 1 steve" ) }
498
499
499
500
Thread .sleep(100 )
500
501
val date = Date ()
501
502
502
- bobConversation.send(text = " hey alice 2 bob" )
503
- bobConversation.send(text = " hey alice 3 bob" )
504
- steveConversation.send(text = " hey alice 2 steve" )
505
- steveConversation.send(text = " hey alice 3 steve" )
503
+ runBlocking { bobConversation.send(text = " hey alice 2 bob" ) }
504
+ runBlocking { bobConversation.send(text = " hey alice 3 bob" ) }
505
+ runBlocking { steveConversation.send(text = " hey alice 2 steve" ) }
506
+ runBlocking { steveConversation.send(text = " hey alice 3 steve" ) }
506
507
507
508
val messages = aliceClient.conversations.listBatchMessages(
508
509
listOf (
@@ -753,7 +754,7 @@ class ConversationTest {
753
754
val bobConversation = bobClient.conversations.newConversation(aliceWallet.address)
754
755
val aliceConversation = aliceClient.conversations.newConversation(bobWallet.address)
755
756
val encodedContent = TextCodec ().encode(content = " hi" )
756
- bobConversation.send(encodedContent = encodedContent)
757
+ runBlocking { bobConversation.send(encodedContent = encodedContent) }
757
758
val messages = aliceConversation.messages()
758
759
assertEquals(1 , messages.size)
759
760
assertEquals(" hi" , messages[0 ].content())
@@ -763,7 +764,7 @@ class ConversationTest {
763
764
fun testCanSendEncodedContentV2Message () {
764
765
val bobConversation = bobClient.conversations.newConversation(aliceWallet.address)
765
766
val encodedContent = TextCodec ().encode(content = " hi" )
766
- bobConversation.send(encodedContent = encodedContent)
767
+ runBlocking { bobConversation.send(encodedContent = encodedContent) }
767
768
val messages = bobConversation.messages()
768
769
assertEquals(1 , messages.size)
769
770
assertEquals(" hi" , messages[0 ].content())
@@ -821,7 +822,7 @@ class ConversationTest {
821
822
// Conversations you receive should start as unknown
822
823
assertTrue(isUnknown)
823
824
824
- aliceConversation.send(content = " hey bob" )
825
+ runBlocking { aliceConversation.send(content = " hey bob" ) }
825
826
aliceClient.contacts.refreshConsentList()
826
827
val isNowAllowed = aliceConversation.consentState() == ConsentState .ALLOWED
827
828
0 commit comments