From b3615432efe6f9a1f1a71328c08ca9404ca94767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noe=CC=81=20Malzieu?= Date: Thu, 26 Sep 2024 17:26:52 +0200 Subject: [PATCH 1/6] Add delay after streaming to make sure the stream is opened --- example/src/tests/groupTests.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/example/src/tests/groupTests.ts b/example/src/tests/groupTests.ts index 494fb2327..cc0ec19f7 100644 --- a/example/src/tests/groupTests.ts +++ b/example/src/tests/groupTests.ts @@ -993,6 +993,8 @@ test('can cancel streams', async () => { messageCallbacks++ }, true) + await delayToPropogate() + await group.send('hello') await delayToPropogate() From e9f62465331dc733933fde49e5dab6a1bb3ecffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noe=CC=81=20Malzieu?= Date: Thu, 26 Sep 2024 17:29:03 +0200 Subject: [PATCH 2/6] Always stream group even if we know it --- src/lib/Conversations.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Conversations.ts b/src/lib/Conversations.ts index 55a6b9c65..fc8b8a656 100644 --- a/src/lib/Conversations.ts +++ b/src/lib/Conversations.ts @@ -146,7 +146,7 @@ export default class Conversations< const groupsSubscription = XMTPModule.emitter.addListener( EventTypes.Group, async ({ inboxId, group }: { inboxId: string; group: GroupParams }) => { - if (this.known[group.id] || this.client.inboxId !== inboxId) { + if (this.client.inboxId !== inboxId) { return } this.known[group.id] = true From 9a3040045eba2ad63fdce9875c3e3335c9d5c959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noe=CC=81=20Malzieu?= Date: Thu, 26 Sep 2024 17:47:31 +0200 Subject: [PATCH 3/6] Add a test for broken streaming between groups & messages --- example/src/tests/groupTests.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/example/src/tests/groupTests.ts b/example/src/tests/groupTests.ts index cc0ec19f7..df07c49c7 100644 --- a/example/src/tests/groupTests.ts +++ b/example/src/tests/groupTests.ts @@ -2323,6 +2323,38 @@ test('only streams groups that can be decrypted', async () => { return true }) +test('can stream groups and messages', async () => { + for (let index = 0; index < 15; index++) { + console.log(`stream groups & messages: test ${index}`) + const [alixClient, boClient] = await createClients(2) + + // Start streaming groups + const groups: Group[] = [] + await alixClient.conversations.streamGroups(async (group: Group) => { + groups.push(group) + }) + // Stream messages twice + await alixClient.conversations.streamAllMessages( + async (message) => {}, + true + ) + await alixClient.conversations.streamAllMessages( + async (message) => {}, + true + ) + + // bo creates a group with alix so a stream callback is fired + // eslint-disable-next-line @typescript-eslint/no-unused-vars + await boClient.conversations.newGroup([alixClient.address]) + await delayToPropogate(500) + if ((groups.length as number) !== 1) { + throw Error(`Unexpected num groups (should be 1): ${groups.length}`) + } + } + + return true +}) + // Commenting this out so it doesn't block people, but nice to have? // test('can stream messages for a long time', async () => { // const bo = await Client.createRandom({ env: 'local', enableV3: true }) From a7cd85d671573c09dc25f188c3dc0a109bc1c248 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Sun, 29 Sep 2024 11:43:25 -0600 Subject: [PATCH 4/6] get on to the latest pod --- example/ios/Podfile.lock | 8 ++++---- .../xmtpreactnativesdkexample.xcodeproj/project.pbxproj | 2 -- ios/XMTPReactNative.podspec | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 7fda21ca3..ddd511099 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -449,7 +449,7 @@ PODS: - GenericJSON (~> 2.0) - Logging (~> 1.0.0) - secp256k1.swift (~> 0.1) - - XMTP (0.14.17): + - XMTP (0.14.18): - Connect-Swift (= 0.12.0) - GzipSwift - LibXMTP (= 0.5.8-beta7) @@ -458,7 +458,7 @@ PODS: - ExpoModulesCore - MessagePacker - secp256k1.swift - - XMTP (= 0.14.17) + - XMTP (= 0.14.18) - Yoga (1.14.0) DEPENDENCIES: @@ -763,8 +763,8 @@ SPEC CHECKSUMS: secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1 web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959 - XMTP: 64600a3216ef8bfb074a128cffe37458b23c52fd - XMTPReactNative: 39e85c5215efa8cb7900285dc95319402758d85b + XMTP: ad01d17d7b513704b00033ee72ed544e48d38fcf + XMTPReactNative: 4f4256484300b6f1cbbfbdcbbf110c00c5513760 Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9 PODFILE CHECKSUM: 0e6fe50018f34e575d38dc6a1fdf1f99c9596cdd diff --git a/example/ios/xmtpreactnativesdkexample.xcodeproj/project.pbxproj b/example/ios/xmtpreactnativesdkexample.xcodeproj/project.pbxproj index 3388e7aa2..2d41f01a2 100644 --- a/example/ios/xmtpreactnativesdkexample.xcodeproj/project.pbxproj +++ b/example/ios/xmtpreactnativesdkexample.xcodeproj/project.pbxproj @@ -294,12 +294,10 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-xmtpreactnativesdkexample/Pods-xmtpreactnativesdkexample-frameworks.sh", "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes-engine/Pre-built/hermes.framework/hermes", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/hermes.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/ios/XMTPReactNative.podspec b/ios/XMTPReactNative.podspec index dd72e3ee0..3504376bb 100644 --- a/ios/XMTPReactNative.podspec +++ b/ios/XMTPReactNative.podspec @@ -26,5 +26,5 @@ Pod::Spec.new do |s| s.source_files = "**/*.{h,m,swift}" s.dependency 'secp256k1.swift' s.dependency "MessagePacker" - s.dependency "XMTP", "= 0.14.17" + s.dependency "XMTP", "= 0.14.18" end From 7b4d5f1955ef8b2f697998e8ad3c8effc5e71da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noe=CC=81=20Malzieu?= Date: Mon, 30 Sep 2024 10:59:24 +0200 Subject: [PATCH 5/6] delay before checking group stream --- example/src/tests/groupTests.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/example/src/tests/groupTests.ts b/example/src/tests/groupTests.ts index d16a8eb21..54a3bb5c5 100644 --- a/example/src/tests/groupTests.ts +++ b/example/src/tests/groupTests.ts @@ -3,7 +3,13 @@ import { Platform } from 'expo-modules-core' import RNFS from 'react-native-fs' import { DecodedMessage } from 'xmtp-react-native-sdk/lib/DecodedMessage' -import { Test, assert, createClients, createGroups, delayToPropogate } from './test-utils' +import { + Test, + assert, + createClients, + createGroups, + delayToPropogate, +} from './test-utils' import { Client, Conversation, @@ -2108,6 +2114,8 @@ test('can list groups does not fork', async () => { `should have 5 messages on second load received ${boMessages2.length}` ) + await delayToPropogate(500) + assert(groupCallbacks === 1, 'group stream should have received 1 group') return true From 16b296d576bdedf93ebec001d926ed600aefb67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noe=CC=81=20Malzieu?= Date: Mon, 30 Sep 2024 11:25:33 +0200 Subject: [PATCH 6/6] fix: group stream error