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