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

Fix peer addresses actually returns peer addresses #282

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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 @@ -4,6 +4,7 @@ import android.util.Base64
import android.util.Base64.NO_WRAP
import com.google.gson.GsonBuilder
import org.xmtp.android.library.Client
import org.xmtp.android.library.Conversation
import org.xmtp.android.library.Group
import org.xmtp.android.library.toHex
import uniffi.xmtpv3.GroupPermissions
Expand All @@ -20,7 +21,7 @@ class GroupWrapper {
"clientAddress" to client.address,
"id" to group.id.toHex(),
"createdAt" to group.createdAt.time,
"peerAddresses" to group.memberAddresses(),
"peerAddresses" to Conversation.Group(group).peerAddresses,
"version" to "GROUP",
"topic" to group.id.toHex(),
"permissionLevel" to permissionString,
Expand Down
16 changes: 16 additions & 0 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
appVersion: 'Testing/0.0.0',
enableAlphaMls: true,
})
} catch (error: any) {

Check warning on line 85 in example/src/tests/groupTests.ts

View workflow job for this annotation

GitHub Actions / lint

'error' is defined but never used
return true
}
throw new Error(
Expand Down Expand Up @@ -131,6 +131,10 @@
if (memberAddresses.length !== 3) {
throw new Error('num group members should be 3')
}
const peerAddresses = await aliceGroup.peerAddresses
if (peerAddresses.length !== 2) {
throw new Error('num peer group members should be 2')
}
const lowercasedAddresses: string[] = memberAddresses.map((s) =>
s.toLowerCase()
)
Expand All @@ -144,6 +148,18 @@
throw new Error('missing address')
}

const lowercasedPeerAddresses: string[] = peerAddresses.map((s) =>
s.toLowerCase()
)
if (
!(
lowercasedPeerAddresses.includes(bobClient.address.toLowerCase()) &&
lowercasedPeerAddresses.includes(camClient.address.toLowerCase())
)
) {
throw new Error('should include self')
}

// Alice can send messages
await aliceGroup.send('hello, world')
await aliceGroup.send('gm')
Expand Down
2 changes: 1 addition & 1 deletion ios/Wrappers/GroupWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct GroupWrapper {
"clientAddress": client.address,
"id": group.id.toHex,
"createdAt": UInt64(group.createdAt.timeIntervalSince1970 * 1000),
"peerAddresses": group.memberAddresses,
"peerAddresses": XMTP.Conversation.group(group).peerAddresses,
"version": "GROUP",
"topic": group.id.toHex,
"permissionLevel": permissionString,
Expand Down
Loading