Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Streaming and Threading Improvements #192

Merged
merged 30 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bc2738e
bump the binaries
nplasterer Feb 29, 2024
35d5427
Merge branch 'main' of https://github.com/xmtp/xmtp-android into np/b…
nplasterer Mar 2, 2024
7e16d6c
add v2 rust client to the client creation methods
nplasterer Mar 2, 2024
a740dba
Merge branch 'main' of https://github.com/xmtp/xmtp-android into np/b…
nplasterer Mar 12, 2024
e4152d8
make all send functions suspend
nplasterer Mar 13, 2024
f5ed2fd
fix up the tests to not lock on send
nplasterer Mar 13, 2024
125d1ac
Revert "make all send functions suspend"
nplasterer Mar 13, 2024
10df0c4
Revert "Revert "make all send functions suspend""
nplasterer Mar 13, 2024
5bed136
fix lots of the threading issues
nplasterer Mar 13, 2024
ec9b1e6
fix up the linter errors
nplasterer Mar 13, 2024
bc6343b
Merge branch 'np/bump-latest-rust' of https://github.com/xmtp/xmtp-an…
nplasterer Mar 13, 2024
dabf7bc
bump to the latest rust library
nplasterer Mar 13, 2024
e7c3db6
make delay longer
nplasterer Mar 13, 2024
08d72c1
Merge branch 'np/bump-latest-rust' of https://github.com/xmtp/xmtp-an…
nplasterer Mar 13, 2024
99b09a5
clean up url usuage
nplasterer Mar 13, 2024
c41dc6d
Merge branch 'main' of https://github.com/xmtp/xmtp-android into np/v…
nplasterer Mar 19, 2024
21fa35e
bump to latest rust
nplasterer Mar 20, 2024
4af2695
Merge branch 'main' of https://github.com/xmtp/xmtp-android into np/v…
nplasterer Mar 20, 2024
8992643
incrementally making suspend functions better
nplasterer Mar 20, 2024
ac2155a
remove the fake api client
nplasterer Mar 21, 2024
a74706b
use subscribe2
nplasterer Mar 21, 2024
dde0430
remove rust v2 and the subscribe
nplasterer Mar 21, 2024
0057dfa
remove subscribe entirely
nplasterer Mar 21, 2024
7e14706
make more suspend
nplasterer Mar 21, 2024
9fe6b87
bring back conversation tests
nplasterer Mar 21, 2024
005741a
fix up the linter and some more tests
nplasterer Mar 21, 2024
e59c35b
fix up the tests
nplasterer Mar 21, 2024
9e37fc8
get all the tests passing
nplasterer Mar 21, 2024
ea244de
everything takes a subscribe2 now
nplasterer Mar 21, 2024
6037cd5
clean up the subscribe2 under the hood
nplasterer Mar 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ class AttachmentTest {

val fixtures = fixtures()
val aliceClient = fixtures.aliceClient
val aliceConversation =
val aliceConversation = runBlocking {
aliceClient.conversations.newConversation(fixtures.bob.walletAddress)
}

runBlocking {
aliceConversation.send(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class ClientTest {
fun testHasPrivateKeyBundleV1() {
val fakeWallet = PrivateKeyBuilder()
val client = Client().create(account = fakeWallet)
assertEquals(1, client.privateKeyBundleV1?.preKeysList?.size)
val preKey = client.privateKeyBundleV1?.preKeysList?.get(0)
assertEquals(1, client.privateKeyBundleV1.preKeysList?.size)
val preKey = client.privateKeyBundleV1.preKeysList?.get(0)
assert(preKey?.publicKey?.hasSignature() ?: false)
}

Expand All @@ -50,15 +50,15 @@ class ClientTest {
val fakeWallet = PrivateKeyBuilder()
val client = Client().create(account = fakeWallet)
val bundle = client.privateKeyBundle
val clientFromV1Bundle = Client().buildFromBundle(bundle!!)
val clientFromV1Bundle = Client().buildFromBundle(bundle)
assertEquals(client.address, clientFromV1Bundle.address)
assertEquals(
client.privateKeyBundleV1?.identityKey,
clientFromV1Bundle.privateKeyBundleV1?.identityKey,
client.privateKeyBundleV1.identityKey,
clientFromV1Bundle.privateKeyBundleV1.identityKey,
)
assertEquals(
client.privateKeyBundleV1?.preKeysList,
clientFromV1Bundle.privateKeyBundleV1?.preKeysList,
client.privateKeyBundleV1.preKeysList,
clientFromV1Bundle.privateKeyBundleV1.preKeysList,
)
}

Expand All @@ -67,15 +67,15 @@ class ClientTest {
val fakeWallet = PrivateKeyBuilder()
val client = Client().create(account = fakeWallet)
val bundleV1 = client.v1keys
val clientFromV1Bundle = Client().buildFromV1Bundle(bundleV1!!)
val clientFromV1Bundle = Client().buildFromV1Bundle(bundleV1)
assertEquals(client.address, clientFromV1Bundle.address)
assertEquals(
client.privateKeyBundleV1?.identityKey,
clientFromV1Bundle.privateKeyBundleV1?.identityKey,
client.privateKeyBundleV1.identityKey,
clientFromV1Bundle.privateKeyBundleV1.identityKey,
)
assertEquals(
client.privateKeyBundleV1?.preKeysList,
clientFromV1Bundle.privateKeyBundleV1?.preKeysList,
client.privateKeyBundleV1.preKeysList,
clientFromV1Bundle.privateKeyBundleV1.preKeysList,
)
}

Expand All @@ -93,7 +93,8 @@ class ClientTest {
assert(client.canMessageV3(listOf(client.address)))

val bundle = client.privateKeyBundle
val clientFromV1Bundle = Client().buildFromBundle(bundle, account = fakeWallet, options = options)
val clientFromV1Bundle =
Client().buildFromBundle(bundle, account = fakeWallet, options = options)
assertEquals(client.address, clientFromV1Bundle.address)
assertEquals(
client.privateKeyBundleV1.identityKey,
Expand Down Expand Up @@ -147,8 +148,10 @@ class ClientTest {
appContext = context
)
)
client.conversations.newGroup(listOf(client2.address,))
runBlocking { client.conversations.syncGroups() }
runBlocking {
client.conversations.newGroup(listOf(client2.address))
client.conversations.syncGroups()
}
assertEquals(client.conversations.listGroups().size, 1)

client.deleteLocalDatabase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ class CodecTest {
Client.register(codec = NumberCodec())
val fixtures = fixtures()
val aliceClient = fixtures.aliceClient
val aliceConversation =
val aliceConversation = runBlocking {
aliceClient.conversations.newConversation(fixtures.bob.walletAddress)
}
runBlocking {
aliceConversation.send(
content = 3.14,
Expand All @@ -81,8 +82,9 @@ class CodecTest {
Client.register(codec = CompositeCodec())
val fixtures = fixtures()
val aliceClient = fixtures.aliceClient
val aliceConversation =
val aliceConversation = runBlocking {
aliceClient.conversations.newConversation(fixtures.bob.walletAddress)
}
val textContent = TextCodec().encode(content = "hiya")
val source = DecodedComposite(encodedContent = textContent)
runBlocking {
Expand All @@ -102,8 +104,9 @@ class CodecTest {
Client.register(codec = NumberCodec())
val fixtures = fixtures()
val aliceClient = fixtures.aliceClient!!
val aliceConversation =
val aliceConversation = runBlocking {
aliceClient.conversations.newConversation(fixtures.bob.walletAddress)
}
val textContent = TextCodec().encode(content = "sup")
val numberContent = NumberCodec().encode(content = 3.14)
val source = DecodedComposite(
Expand Down Expand Up @@ -131,9 +134,10 @@ class CodecTest {
val codec = NumberCodec()
Client.register(codec = codec)
val fixtures = fixtures()
val aliceClient = fixtures.aliceClient!!
val aliceConversation =
val aliceClient = fixtures.aliceClient
val aliceConversation = runBlocking {
aliceClient.conversations.newConversation(fixtures.bob.walletAddress)
}
runBlocking {
aliceConversation.send(
content = 3.14,
Expand Down Expand Up @@ -165,12 +169,14 @@ class CodecTest {
repeat(5) {
val account = PrivateKeyBuilder()
val client = Client().create(account, clientOptions)
conversations.add(
alixClient.conversations.newConversation(
client.address,
context = InvitationV1ContextBuilder.buildFromConversation(conversationId = "hi")
runBlocking {
conversations.add(
alixClient.conversations.newConversation(
client.address,
context = InvitationV1ContextBuilder.buildFromConversation(conversationId = "hi")
)
)
)
}
}

val thirtyDayPeriodsSinceEpoch = Instant.now().epochSecond / 60 / 60 / 24 / 30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.xmtp.android.library.messages.walletAddress

@RunWith(AndroidJUnit4::class)
class ContactsTest {

Expand Down
Loading
Loading