1
1
package org.xmtp.android.library
2
2
3
+ import android.util.Log
3
4
import androidx.test.ext.junit.runners.AndroidJUnit4
4
5
import kotlinx.coroutines.CoroutineScope
5
6
import kotlinx.coroutines.Dispatchers
@@ -21,6 +22,7 @@ import org.xmtp.android.library.messages.createDeterministic
21
22
import org.xmtp.android.library.messages.getPublicKeyBundle
22
23
import org.xmtp.android.library.messages.toPublicKeyBundle
23
24
import org.xmtp.android.library.messages.walletAddress
25
+ import org.xmtp.proto.keystore.api.v1.Keystore
24
26
import java.lang.Thread.sleep
25
27
import java.util.Date
26
28
@@ -138,4 +140,46 @@ class ConversationsTest {
138
140
139
141
assertEquals(allMessages.size, 15 )
140
142
}
143
+
144
+ @Test
145
+ fun testBigWallet () {
146
+ val privateKeyData = listOf (0x08 , 0x36 , 0x20 , 0x0f , 0xfa , 0xfa , 0x17 , 0xa3 , 0xcb , 0x8b , 0x54 , 0xf2 , 0x2d , 0x6a , 0xfa , 0x60 , 0xb1 , 0x3d , 0xa4 , 0x87 , 0x26 , 0x54 , 0x32 , 0x41 , 0xad , 0xc5 , 0xc2 , 0x50 , 0xdb , 0xb0 , 0xe0 , 0xcd )
147
+ .map { it.toByte() }
148
+ .toByteArray()
149
+ // Use hardcoded privateKey
150
+ val privateKey = PrivateKeyBuilder .buildFromPrivateKeyData(privateKeyData)
151
+ val privateKeyBuilder = PrivateKeyBuilder (privateKey)
152
+ val options =
153
+ ClientOptions (api = ClientOptions .Api (env = XMTPEnvironment .DEV ))
154
+ val client = Client ().create(account = privateKeyBuilder, options = options)
155
+
156
+ runBlocking {
157
+ val start = Date ()
158
+ val conversations = client.conversations.list()
159
+ val end = Date ()
160
+ Log .d(" LOPI" , " Loaded ${conversations.size} conversations in ${(end.time - start.time) / 1000.0 } s" )
161
+
162
+
163
+ val start2 = Date ()
164
+ val conversations2 = client.conversations.list()
165
+ val end2 = Date ()
166
+ Log .d(" LOPI" , " Second time loaded ${conversations2.size} conversations in ${(end2.time - start2.time) / 1000.0 } s" )
167
+
168
+ val last500Topics = conversations.takeLast(2000 ).map { it.toTopicData().toByteString() }
169
+ val client2 = Client ().create(account = privateKeyBuilder, options = options)
170
+ for (topic in last500Topics) {
171
+ client2.conversations.importTopicData(Keystore .TopicMap .TopicData .parseFrom(topic))
172
+ }
173
+
174
+ val start3 = Date ()
175
+ val conversations3 = client2.conversations.list()
176
+ val end3 = Date ()
177
+ Log .d(" LOPI" , " Loaded ${conversations3.size} conversations in ${(end3.time - start3.time) / 1000.0 } s" )
178
+
179
+ val start4 = Date ()
180
+ val conversations4 = client2.conversations.list()
181
+ val end4 = Date ()
182
+ Log .d(" LOPI" , " Second time loaded ${conversations4.size} conversations in ${(end4.time - start4.time) / 1000.0 } s" )
183
+ }
184
+ }
141
185
}
0 commit comments