Skip to content

Commit

Permalink
Merge pull request #487 from xmtp/np/streaming-reproduction-test
Browse files Browse the repository at this point in the history
Canceling streams cancels underlying stream
  • Loading branch information
nmalzieu authored Sep 3, 2024
2 parents 4b126a6 + 72c8284 commit ba1f330
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
14 changes: 7 additions & 7 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ PODS:
- hermes-engine/Pre-built (= 0.71.14)
- hermes-engine/Pre-built (0.71.14)
- libevent (2.1.12)
- LibXMTP (0.5.8-beta1)
- LibXMTP (0.5.8-beta3)
- Logging (1.0.0)
- MessagePacker (0.4.7)
- MMKV (1.3.9):
Expand Down Expand Up @@ -449,16 +449,16 @@ PODS:
- GenericJSON (~> 2.0)
- Logging (~> 1.0.0)
- secp256k1.swift (~> 0.1)
- XMTP (0.14.9):
- XMTP (0.14.11):
- Connect-Swift (= 0.12.0)
- GzipSwift
- LibXMTP (= 0.5.8-beta1)
- LibXMTP (= 0.5.8-beta3)
- web3.swift
- XMTPReactNative (0.1.0):
- ExpoModulesCore
- MessagePacker
- secp256k1.swift
- XMTP (= 0.14.9)
- XMTP (= 0.14.11)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -711,7 +711,7 @@ SPEC CHECKSUMS:
GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa
hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
LibXMTP: b7f9a97c56120771b3e99017f3454063f0388fb6
LibXMTP: c7cad19e8ac4721254df8f5b3c60677362b5f0d3
Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26
MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02
MMKV: 817ba1eea17421547e01e087285606eb270a8dcb
Expand Down Expand Up @@ -763,8 +763,8 @@ SPEC CHECKSUMS:
secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634
SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1
web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959
XMTP: ba28e0b3732e20beff61d2f9b7fe38561f5a6f72
XMTPReactNative: 8c15853c59fffddffa1c19b68acd766929ca10b2
XMTP: cb6058bf6e097b453c502b8dd00f7ddaf68a9c20
XMTPReactNative: 2f169f481dc0c97acc90298525837f0d363bc33f
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9

PODFILE CHECKSUM: 0e6fe50018f34e575d38dc6a1fdf1f99c9596cdd
Expand Down
47 changes: 47 additions & 0 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Wallet } from 'ethers'
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, delayToPropogate } from './test-utils'
Expand Down Expand Up @@ -957,6 +958,52 @@ test('can remove and add members from a group by inbox id', async () => {
return true
})

test('can cancel streams', async () => {
const [alix, bo] = await createClients(2)
let messageCallbacks = 0

await bo.conversations.streamAllMessages(async () => {
messageCallbacks++
}, true)

const group = await alix.conversations.newGroup([bo.address])
await group.send('hello')
await delayToPropogate()

assert(
messageCallbacks === 1,
'message stream should have received 1 message'
)

await bo.conversations.cancelStreamAllMessages()
await delayToPropogate()

await group.send('hello')
await group.send('hello')
await group.send('hello')

await delayToPropogate()

assert(
messageCallbacks === 1,
'message stream should still only received 1 message'
)

await bo.conversations.streamAllMessages(async () => {
messageCallbacks++
}, true)

await group.send('hello')
await delayToPropogate()

assert(
messageCallbacks === 2,
'message stream should have received 2 message'
)

return true
})

test('can stream both groups and messages at same time', async () => {
const [alix, bo] = await createClients(2)

Expand Down
2 changes: 1 addition & 1 deletion ios/XMTPReactNative.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.10"
s.dependency "XMTP", "= 0.14.11"
end

0 comments on commit ba1f330

Please sign in to comment.