From 32125686862f70dafa3694344e7ab5b67fa81070 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 12 Jun 2024 19:41:12 -0700 Subject: [PATCH 1/3] add the repro test --- example/ios/Podfile.lock | 772 +++++++++ example/src/tests/groupTests.ts | 2779 ++++++++++++++++--------------- example/src/tests/test-utils.ts | 2 +- 3 files changed, 2177 insertions(+), 1376 deletions(-) create mode 100644 example/ios/Podfile.lock diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock new file mode 100644 index 000000000..0f23166df --- /dev/null +++ b/example/ios/Podfile.lock @@ -0,0 +1,772 @@ +PODS: + - BigInt (5.0.0) + - boost (1.76.0) + - CoinbaseWalletSDK/Client (1.0.4) + - CoinbaseWalletSDK/CrossPlatform (1.0.4): + - CoinbaseWalletSDK/Client + - CoinbaseWalletSDKExpo (1.0.10): + - CoinbaseWalletSDK/CrossPlatform (= 1.0.4) + - ExpoModulesCore + - Connect-Swift (0.12.0): + - SwiftProtobuf (~> 1.25.2) + - DoubleConversion (1.1.6) + - EXApplication (5.4.0): + - ExpoModulesCore + - EXConstants (14.2.1): + - ExpoModulesCore + - EXFileSystem (15.2.2): + - ExpoModulesCore + - EXFont (11.1.1): + - ExpoModulesCore + - EXImageLoader (4.4.0): + - ExpoModulesCore + - React-Core + - Expo (48.0.21): + - ExpoModulesCore + - ExpoClipboard (4.5.0): + - ExpoModulesCore + - ExpoDocumentPicker (11.7.0): + - ExpoModulesCore + - ExpoImagePicker (14.5.0): + - ExpoModulesCore + - ExpoKeepAwake (12.0.1): + - ExpoModulesCore + - ExpoModulesCore (1.2.7): + - React-Core + - React-RCTAppDelegate + - ReactCommon/turbomodule/core + - ExpoSecureStore (12.5.0): + - ExpoModulesCore + - EXSplashScreen (0.18.2): + - ExpoModulesCore + - React-Core + - FBLazyVector (0.71.14) + - FBReactNativeSpec (0.71.14): + - RCT-Folly (= 2021.07.22.00) + - RCTRequired (= 0.71.14) + - RCTTypeSafety (= 0.71.14) + - React-Core (= 0.71.14) + - React-jsi (= 0.71.14) + - ReactCommon/turbomodule/core (= 0.71.14) + - fmt (6.2.1) + - GenericJSON (2.0.2) + - glog (0.3.5) + - GzipSwift (5.1.1) + - hermes-engine (0.71.14): + - hermes-engine/Pre-built (= 0.71.14) + - hermes-engine/Pre-built (0.71.14) + - libevent (2.1.12) + - LibXMTP (0.5.1-beta1) + - Logging (1.0.0) + - MessagePacker (0.4.7) + - MMKV (1.3.5): + - MMKVCore (~> 1.3.5) + - MMKVCore (1.3.5) + - OpenSSL-Universal (1.1.2200) + - RCT-Folly (2021.07.22.00): + - boost + - DoubleConversion + - fmt (~> 6.2.1) + - glog + - RCT-Folly/Default (= 2021.07.22.00) + - RCT-Folly/Default (2021.07.22.00): + - boost + - DoubleConversion + - fmt (~> 6.2.1) + - glog + - RCT-Folly/Futures (2021.07.22.00): + - boost + - DoubleConversion + - fmt (~> 6.2.1) + - glog + - libevent + - RCTRequired (0.71.14) + - RCTTypeSafety (0.71.14): + - FBLazyVector (= 0.71.14) + - RCTRequired (= 0.71.14) + - React-Core (= 0.71.14) + - React (0.71.14): + - React-Core (= 0.71.14) + - React-Core/DevSupport (= 0.71.14) + - React-Core/RCTWebSocket (= 0.71.14) + - React-RCTActionSheet (= 0.71.14) + - React-RCTAnimation (= 0.71.14) + - React-RCTBlob (= 0.71.14) + - React-RCTImage (= 0.71.14) + - React-RCTLinking (= 0.71.14) + - React-RCTNetwork (= 0.71.14) + - React-RCTSettings (= 0.71.14) + - React-RCTText (= 0.71.14) + - React-RCTVibration (= 0.71.14) + - React-callinvoker (0.71.14) + - React-Codegen (0.71.14): + - FBReactNativeSpec + - hermes-engine + - RCT-Folly + - RCTRequired + - RCTTypeSafety + - React-Core + - React-jsi + - React-jsiexecutor + - ReactCommon/turbomodule/bridging + - ReactCommon/turbomodule/core + - React-Core (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default (= 0.71.14) + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-Core/CoreModulesHeaders (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-Core/Default (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-Core/DevSupport (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default (= 0.71.14) + - React-Core/RCTWebSocket (= 0.71.14) + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-jsinspector (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-Core/RCTActionSheetHeaders (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-Core/RCTAnimationHeaders (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-Core/RCTBlobHeaders (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-Core/RCTImageHeaders (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-Core/RCTLinkingHeaders (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-Core/RCTNetworkHeaders (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-Core/RCTSettingsHeaders (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-Core/RCTTextHeaders (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-Core/RCTVibrationHeaders (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-Core/RCTWebSocket (0.71.14): + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Core/Default (= 0.71.14) + - React-cxxreact (= 0.71.14) + - React-hermes + - React-jsi (= 0.71.14) + - React-jsiexecutor (= 0.71.14) + - React-perflogger (= 0.71.14) + - Yoga + - React-CoreModules (0.71.14): + - RCT-Folly (= 2021.07.22.00) + - RCTTypeSafety (= 0.71.14) + - React-Codegen (= 0.71.14) + - React-Core/CoreModulesHeaders (= 0.71.14) + - React-jsi (= 0.71.14) + - React-RCTBlob + - React-RCTImage (= 0.71.14) + - ReactCommon/turbomodule/core (= 0.71.14) + - React-cxxreact (0.71.14): + - boost (= 1.76.0) + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-callinvoker (= 0.71.14) + - React-jsi (= 0.71.14) + - React-jsinspector (= 0.71.14) + - React-logger (= 0.71.14) + - React-perflogger (= 0.71.14) + - React-runtimeexecutor (= 0.71.14) + - React-hermes (0.71.14): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - RCT-Folly/Futures (= 2021.07.22.00) + - React-cxxreact (= 0.71.14) + - React-jsi + - React-jsiexecutor (= 0.71.14) + - React-jsinspector (= 0.71.14) + - React-perflogger (= 0.71.14) + - React-jsi (0.71.14): + - boost (= 1.76.0) + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-jsiexecutor (0.71.14): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-cxxreact (= 0.71.14) + - React-jsi (= 0.71.14) + - React-perflogger (= 0.71.14) + - React-jsinspector (0.71.14) + - React-logger (0.71.14): + - glog + - react-native-blob-util (0.19.6): + - React-Core + - react-native-config (1.5.1): + - react-native-config/App (= 1.5.1) + - react-native-config/App (1.5.1): + - React-Core + - react-native-encrypted-storage (4.0.3): + - React-Core + - react-native-get-random-values (1.11.0): + - React-Core + - react-native-mmkv (2.11.0): + - MMKV (>= 1.2.13) + - React-Core + - react-native-netinfo (11.2.1): + - React-Core + - react-native-quick-base64 (2.0.8): + - React-Core + - react-native-quick-crypto (0.6.1): + - OpenSSL-Universal + - React + - React-callinvoker + - React-Core + - react-native-randombytes (3.6.1): + - React-Core + - react-native-safe-area-context (4.5.0): + - RCT-Folly + - RCTRequired + - RCTTypeSafety + - React-Core + - ReactCommon/turbomodule/core + - react-native-sqlite-storage (6.0.1): + - React-Core + - react-native-webview (13.8.1): + - RCT-Folly (= 2021.07.22.00) + - React-Core + - React-perflogger (0.71.14) + - React-RCTActionSheet (0.71.14): + - React-Core/RCTActionSheetHeaders (= 0.71.14) + - React-RCTAnimation (0.71.14): + - RCT-Folly (= 2021.07.22.00) + - RCTTypeSafety (= 0.71.14) + - React-Codegen (= 0.71.14) + - React-Core/RCTAnimationHeaders (= 0.71.14) + - React-jsi (= 0.71.14) + - ReactCommon/turbomodule/core (= 0.71.14) + - React-RCTAppDelegate (0.71.14): + - RCT-Folly + - RCTRequired + - RCTTypeSafety + - React-Core + - ReactCommon/turbomodule/core + - React-RCTBlob (0.71.14): + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-Codegen (= 0.71.14) + - React-Core/RCTBlobHeaders (= 0.71.14) + - React-Core/RCTWebSocket (= 0.71.14) + - React-jsi (= 0.71.14) + - React-RCTNetwork (= 0.71.14) + - ReactCommon/turbomodule/core (= 0.71.14) + - React-RCTImage (0.71.14): + - RCT-Folly (= 2021.07.22.00) + - RCTTypeSafety (= 0.71.14) + - React-Codegen (= 0.71.14) + - React-Core/RCTImageHeaders (= 0.71.14) + - React-jsi (= 0.71.14) + - React-RCTNetwork (= 0.71.14) + - ReactCommon/turbomodule/core (= 0.71.14) + - React-RCTLinking (0.71.14): + - React-Codegen (= 0.71.14) + - React-Core/RCTLinkingHeaders (= 0.71.14) + - React-jsi (= 0.71.14) + - ReactCommon/turbomodule/core (= 0.71.14) + - React-RCTNetwork (0.71.14): + - RCT-Folly (= 2021.07.22.00) + - RCTTypeSafety (= 0.71.14) + - React-Codegen (= 0.71.14) + - React-Core/RCTNetworkHeaders (= 0.71.14) + - React-jsi (= 0.71.14) + - ReactCommon/turbomodule/core (= 0.71.14) + - React-RCTSettings (0.71.14): + - RCT-Folly (= 2021.07.22.00) + - RCTTypeSafety (= 0.71.14) + - React-Codegen (= 0.71.14) + - React-Core/RCTSettingsHeaders (= 0.71.14) + - React-jsi (= 0.71.14) + - ReactCommon/turbomodule/core (= 0.71.14) + - React-RCTText (0.71.14): + - React-Core/RCTTextHeaders (= 0.71.14) + - React-RCTVibration (0.71.14): + - RCT-Folly (= 2021.07.22.00) + - React-Codegen (= 0.71.14) + - React-Core/RCTVibrationHeaders (= 0.71.14) + - React-jsi (= 0.71.14) + - ReactCommon/turbomodule/core (= 0.71.14) + - React-runtimeexecutor (0.71.14): + - React-jsi (= 0.71.14) + - ReactCommon/turbomodule/bridging (0.71.14): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-callinvoker (= 0.71.14) + - React-Core (= 0.71.14) + - React-cxxreact (= 0.71.14) + - React-jsi (= 0.71.14) + - React-logger (= 0.71.14) + - React-perflogger (= 0.71.14) + - ReactCommon/turbomodule/core (0.71.14): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2021.07.22.00) + - React-callinvoker (= 0.71.14) + - React-Core (= 0.71.14) + - React-cxxreact (= 0.71.14) + - React-jsi (= 0.71.14) + - React-logger (= 0.71.14) + - React-perflogger (= 0.71.14) + - RNCAsyncStorage (1.21.0): + - React-Core + - RNFS (2.20.0): + - React-Core + - RNScreens (3.20.0): + - React-Core + - React-RCTImage + - RNSVG (13.14.0): + - React-Core + - secp256k1.swift (0.1.4) + - SwiftProtobuf (1.25.2) + - web3.swift (1.6.0): + - BigInt (~> 5.0.0) + - GenericJSON (~> 2.0) + - Logging (~> 1.0.0) + - secp256k1.swift (~> 0.1) + - XMTP (0.11.5): + - Connect-Swift (= 0.12.0) + - GzipSwift + - LibXMTP (= 0.5.1-beta1) + - web3.swift + - XMTPReactNative (0.1.0): + - ExpoModulesCore + - MessagePacker + - secp256k1.swift + - XMTP (= 0.11.5) + - Yoga (1.14.0) + +DEPENDENCIES: + - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`) + - "CoinbaseWalletSDKExpo (from `../node_modules/@coinbase/wallet-mobile-sdk/ios`)" + - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) + - EXApplication (from `../node_modules/expo-application/ios`) + - EXConstants (from `../node_modules/expo-constants/ios`) + - EXFileSystem (from `../node_modules/expo-file-system/ios`) + - EXFont (from `../node_modules/expo-font/ios`) + - EXImageLoader (from `../node_modules/expo-image-loader/ios`) + - Expo (from `../node_modules/expo`) + - ExpoClipboard (from `../node_modules/expo-clipboard/ios`) + - ExpoDocumentPicker (from `../node_modules/expo-document-picker/ios`) + - ExpoImagePicker (from `../node_modules/expo-image-picker/ios`) + - ExpoKeepAwake (from `../node_modules/expo-keep-awake/ios`) + - ExpoModulesCore (from `../node_modules/expo-modules-core`) + - ExpoSecureStore (from `../node_modules/expo-secure-store/ios`) + - EXSplashScreen (from `../node_modules/expo-splash-screen/ios`) + - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) + - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) + - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) + - hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`) + - libevent (~> 2.1.12) + - OpenSSL-Universal (= 1.1.2200) + - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) + - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) + - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) + - React (from `../node_modules/react-native/`) + - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) + - React-Codegen (from `build/generated/ios`) + - React-Core (from `../node_modules/react-native/`) + - React-Core/RCTWebSocket (from `../node_modules/react-native/`) + - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) + - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) + - React-hermes (from `../node_modules/react-native/ReactCommon/hermes`) + - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) + - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) + - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) + - React-logger (from `../node_modules/react-native/ReactCommon/logger`) + - react-native-blob-util (from `../node_modules/react-native-blob-util`) + - react-native-config (from `../node_modules/react-native-config`) + - react-native-encrypted-storage (from `../node_modules/react-native-encrypted-storage`) + - react-native-get-random-values (from `../node_modules/react-native-get-random-values`) + - react-native-mmkv (from `../node_modules/react-native-mmkv`) + - "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)" + - react-native-quick-base64 (from `../node_modules/react-native-quick-base64`) + - react-native-quick-crypto (from `../node_modules/react-native-quick-crypto`) + - react-native-randombytes (from `../node_modules/react-native-randombytes`) + - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) + - react-native-sqlite-storage (from `../node_modules/react-native-sqlite-storage`) + - react-native-webview (from `../node_modules/react-native-webview`) + - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`) + - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) + - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) + - React-RCTAppDelegate (from `../node_modules/react-native/Libraries/AppDelegate`) + - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) + - React-RCTImage (from `../node_modules/react-native/Libraries/Image`) + - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`) + - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`) + - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`) + - React-RCTText (from `../node_modules/react-native/Libraries/Text`) + - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) + - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`) + - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) + - "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)" + - RNFS (from `../node_modules/react-native-fs`) + - RNScreens (from `../node_modules/react-native-screens`) + - RNSVG (from `../node_modules/react-native-svg`) + - XMTPReactNative (from `../../ios`) + - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) + +SPEC REPOS: + trunk: + - BigInt + - CoinbaseWalletSDK + - Connect-Swift + - fmt + - GenericJSON + - GzipSwift + - libevent + - LibXMTP + - Logging + - MessagePacker + - MMKV + - MMKVCore + - OpenSSL-Universal + - secp256k1.swift + - SwiftProtobuf + - web3.swift + - XMTP + +EXTERNAL SOURCES: + boost: + :podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec" + CoinbaseWalletSDKExpo: + :path: "../node_modules/@coinbase/wallet-mobile-sdk/ios" + DoubleConversion: + :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" + EXApplication: + :path: "../node_modules/expo-application/ios" + EXConstants: + :path: "../node_modules/expo-constants/ios" + EXFileSystem: + :path: "../node_modules/expo-file-system/ios" + EXFont: + :path: "../node_modules/expo-font/ios" + EXImageLoader: + :path: "../node_modules/expo-image-loader/ios" + Expo: + :path: "../node_modules/expo" + ExpoClipboard: + :path: "../node_modules/expo-clipboard/ios" + ExpoDocumentPicker: + :path: "../node_modules/expo-document-picker/ios" + ExpoImagePicker: + :path: "../node_modules/expo-image-picker/ios" + ExpoKeepAwake: + :path: "../node_modules/expo-keep-awake/ios" + ExpoModulesCore: + :path: "../node_modules/expo-modules-core" + ExpoSecureStore: + :path: "../node_modules/expo-secure-store/ios" + EXSplashScreen: + :path: "../node_modules/expo-splash-screen/ios" + FBLazyVector: + :path: "../node_modules/react-native/Libraries/FBLazyVector" + FBReactNativeSpec: + :path: "../node_modules/react-native/React/FBReactNativeSpec" + glog: + :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" + hermes-engine: + :podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec" + RCT-Folly: + :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" + RCTRequired: + :path: "../node_modules/react-native/Libraries/RCTRequired" + RCTTypeSafety: + :path: "../node_modules/react-native/Libraries/TypeSafety" + React: + :path: "../node_modules/react-native/" + React-callinvoker: + :path: "../node_modules/react-native/ReactCommon/callinvoker" + React-Codegen: + :path: build/generated/ios + React-Core: + :path: "../node_modules/react-native/" + React-CoreModules: + :path: "../node_modules/react-native/React/CoreModules" + React-cxxreact: + :path: "../node_modules/react-native/ReactCommon/cxxreact" + React-hermes: + :path: "../node_modules/react-native/ReactCommon/hermes" + React-jsi: + :path: "../node_modules/react-native/ReactCommon/jsi" + React-jsiexecutor: + :path: "../node_modules/react-native/ReactCommon/jsiexecutor" + React-jsinspector: + :path: "../node_modules/react-native/ReactCommon/jsinspector" + React-logger: + :path: "../node_modules/react-native/ReactCommon/logger" + react-native-blob-util: + :path: "../node_modules/react-native-blob-util" + react-native-config: + :path: "../node_modules/react-native-config" + react-native-encrypted-storage: + :path: "../node_modules/react-native-encrypted-storage" + react-native-get-random-values: + :path: "../node_modules/react-native-get-random-values" + react-native-mmkv: + :path: "../node_modules/react-native-mmkv" + react-native-netinfo: + :path: "../node_modules/@react-native-community/netinfo" + react-native-quick-base64: + :path: "../node_modules/react-native-quick-base64" + react-native-quick-crypto: + :path: "../node_modules/react-native-quick-crypto" + react-native-randombytes: + :path: "../node_modules/react-native-randombytes" + react-native-safe-area-context: + :path: "../node_modules/react-native-safe-area-context" + react-native-sqlite-storage: + :path: "../node_modules/react-native-sqlite-storage" + react-native-webview: + :path: "../node_modules/react-native-webview" + React-perflogger: + :path: "../node_modules/react-native/ReactCommon/reactperflogger" + React-RCTActionSheet: + :path: "../node_modules/react-native/Libraries/ActionSheetIOS" + React-RCTAnimation: + :path: "../node_modules/react-native/Libraries/NativeAnimation" + React-RCTAppDelegate: + :path: "../node_modules/react-native/Libraries/AppDelegate" + React-RCTBlob: + :path: "../node_modules/react-native/Libraries/Blob" + React-RCTImage: + :path: "../node_modules/react-native/Libraries/Image" + React-RCTLinking: + :path: "../node_modules/react-native/Libraries/LinkingIOS" + React-RCTNetwork: + :path: "../node_modules/react-native/Libraries/Network" + React-RCTSettings: + :path: "../node_modules/react-native/Libraries/Settings" + React-RCTText: + :path: "../node_modules/react-native/Libraries/Text" + React-RCTVibration: + :path: "../node_modules/react-native/Libraries/Vibration" + React-runtimeexecutor: + :path: "../node_modules/react-native/ReactCommon/runtimeexecutor" + ReactCommon: + :path: "../node_modules/react-native/ReactCommon" + RNCAsyncStorage: + :path: "../node_modules/@react-native-async-storage/async-storage" + RNFS: + :path: "../node_modules/react-native-fs" + RNScreens: + :path: "../node_modules/react-native-screens" + RNSVG: + :path: "../node_modules/react-native-svg" + XMTPReactNative: + :path: "../../ios" + Yoga: + :path: "../node_modules/react-native/ReactCommon/yoga" + +SPEC CHECKSUMS: + BigInt: 74b4d88367b0e819d9f77393549226d36faeb0d8 + boost: 57d2868c099736d80fcd648bf211b4431e51a558 + CoinbaseWalletSDK: ea1f37512bbc69ebe07416e3b29bf840f5cc3152 + CoinbaseWalletSDKExpo: c79420eb009f482f768c23b6768fc5b2d7c98777 + Connect-Swift: 1de2ef4a548c59ecaeb9120812dfe0d6e07a0d47 + DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 + EXApplication: 2a0d9abd4feace9c6faedfe541c1dec02e3702cd + EXConstants: f348da07e21b23d2b085e270d7b74f282df1a7d9 + EXFileSystem: 844e86ca9b5375486ecc4ef06d3838d5597d895d + EXFont: 6ea3800df746be7233208d80fe379b8ed74f4272 + EXImageLoader: 03063370bc06ea1825713d3f55fe0455f7c88d04 + Expo: 0d9f112757acc6bf32103eabccf91267780bd580 + ExpoClipboard: d2f0e44d50e5ba07b02f5fb7bd280178b420e24e + ExpoDocumentPicker: d3b6b0ed2dbbc2f05158e0294dd3f4673f386e5f + ExpoImagePicker: 9e5c745cb3e56ee00e1cfe5d6af59caab66ecf1a + ExpoKeepAwake: 69f5f627670d62318410392d03e0b5db0f85759a + ExpoModulesCore: 653958063a301098b541ae4dfed1ac0b98db607b + ExpoSecureStore: 5372610a4bbcf5e50fafbe6f38f8d9c22edf8253 + EXSplashScreen: 0e0a9ba0cf7553094e93213099bd7b42e6e237e9 + FBLazyVector: 12ea01e587c9594e7b144e1bfc86ac4d9ac28fde + FBReactNativeSpec: b6ae48e67aaba46442f84d6f9ba598ccfbe2ee66 + fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 + GenericJSON: 79a840eeb77030962e8cf02a62d36bd413b67626 + glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b + GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa + hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88 + libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 + LibXMTP: f897dba3ea05dd5f8b9d098176cd9cb7c73ad505 + Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26 + MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02 + MMKV: 506311d0494023c2f7e0b62cc1f31b7370fa3cfb + MMKVCore: 9e2e5fd529b64a9fe15f1a7afb3d73b2e27b4db9 + OpenSSL-Universal: 6e1ae0555546e604dbc632a2b9a24a9c46c41ef6 + RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 + RCTRequired: e9df143e880d0e879e7a498dc06923d728809c79 + RCTTypeSafety: c2d89c8308829c12c038ec1f431191eaa0d8c15c + React: 52b89a818f4b2579c98567f3aa8bde880d9e843b + React-callinvoker: 56e399c88c05e037fe99c31978f30e75fad5c286 + React-Codegen: 7ece62f4d4896ad1933f834a7dad697676636318 + React-Core: f06b7b00e0d49433a316760ae61a0f8f5dee6629 + React-CoreModules: bd520e5688b5aa4666965a1b3b8e6d4a2e19df20 + React-cxxreact: ba6a1663685837fa4c2ac97daa95dd2e47f1acdc + React-hermes: c862e573ca0228070936b5ec4f475c3e19e900e0 + React-jsi: 533030c161bcfcbc3a4ad0b357ced8f7b2be457e + React-jsiexecutor: 94cfc1788637ceaf8841ef1f69b10cc0d62baadc + React-jsinspector: 7bf923954b4e035f494b01ac16633963412660d7 + React-logger: 655ff5db8bd922acfbe76a4983ffab048916343e + react-native-blob-util: d8fa1a7f726867907a8e43163fdd8b441d4489ea + react-native-config: 86038147314e2e6d10ea9972022aa171e6b1d4d8 + react-native-encrypted-storage: db300a3f2f0aba1e818417c1c0a6be549038deb7 + react-native-get-random-values: 21325b2244dfa6b58878f51f9aa42821e7ba3d06 + react-native-mmkv: e97c0c79403fb94577e5d902ab1ebd42b0715b43 + react-native-netinfo: 8a7fd3f7130ef4ad2fb4276d5c9f8d3f28d2df3d + react-native-quick-base64: 777057ea4286f806b00259ede65dc79c7c706320 + react-native-quick-crypto: 455c1b411db006dba1026a30681ececb19180187 + react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846 + react-native-safe-area-context: 39c2d8be3328df5d437ac1700f4f3a4f75716acc + react-native-sqlite-storage: f6d515e1c446d1e6d026aa5352908a25d4de3261 + react-native-webview: bdc091de8cf7f8397653e30182efcd9f772e03b3 + React-perflogger: 4987ad83731c23d11813c84263963b0d3028c966 + React-RCTActionSheet: 5ad952b2a9740d87a5bd77280c4bc23f6f89ea0c + React-RCTAnimation: d2de22af3f536cc80bb5b3918e1a455114d1b985 + React-RCTAppDelegate: 27f7d735cad3d522c13008ea80020d350017c422 + React-RCTBlob: b697e0e2e38ec85bd726176851a3b476a490ad33 + React-RCTImage: a07e8c7d4768f62ebc6277e4680f6b979c619967 + React-RCTLinking: d00ae55db37b2c12ebab91135f06f75391c0708d + React-RCTNetwork: b3a401276e5c08487d8a14fdec1720e78b5888db + React-RCTSettings: d606cbac31403604c5d5746e6dab53bb332f9301 + React-RCTText: b3bd40bc71bca0c3e2cc5ce2c40870a438f303b1 + React-RCTVibration: 64e412b9ac684c4edc938fa1187135ada9af7faf + React-runtimeexecutor: ffe826b7b1cfbc32a35ed5b64d5886c0ff75f501 + ReactCommon: 7f3dd5e98a9ec627c6b03d26c062bf37ea9fc888 + RNCAsyncStorage: 618d03a5f52fbccb3d7010076bc54712844c18ef + RNFS: 4ac0f0ea233904cb798630b3c077808c06931688 + RNScreens: 218801c16a2782546d30bd2026bb625c0302d70f + RNSVG: d00c8f91c3cbf6d476451313a18f04d220d4f396 + secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 + SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1 + web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959 + XMTP: 3947ed08f7b1c50878b145e4990e604abf741ba9 + XMTPReactNative: 08e92e5c83de18c18af7e9251f348495a3f41e15 + Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9 + +PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2 + +COCOAPODS: 1.15.2 diff --git a/example/src/tests/groupTests.ts b/example/src/tests/groupTests.ts index e6cf877b8..620f19c66 100644 --- a/example/src/tests/groupTests.ts +++ b/example/src/tests/groupTests.ts @@ -23,1582 +23,1611 @@ function test(name: string, perform: () => Promise) { groupTests.push({ name: String(counter++) + '. ' + name, run: perform }) } -test('can make a MLS V3 client', async () => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const client = await Client.createRandom({ - env: 'local', - appVersion: 'Testing/0.0.0', - enableAlphaMls: true, - }) +test('reproduce streaming error', async () => { + const [alix, bo] = await createClients(2) + console.log('created clients') - return true -}) + let groupCallbacks = 0 + let messageCallbacks = 0 + await bo.conversations.streamGroups(async () => { + console.log('message received') + groupCallbacks++ + }) -test('can delete a local database', async () => { - let [client, anotherClient] = await createClients(2) + await bo.conversations.streamAllMessages(async () => { + console.log('message received') + messageCallbacks++ + }, true) - await client.conversations.newGroup([anotherClient.address]) - await client.conversations.syncGroups() - assert( - (await client.conversations.listGroups()).length === 1, - `should have a group size of 1 but was ${ - (await client.conversations.listGroups()).length - }` - ) + const group = await alix.conversations.newGroup([bo.address]) + await group.send('hello') - await client.deleteLocalDatabase() - client = await Client.createRandom({ - env: 'local', - appVersion: 'Testing/0.0.0', - enableAlphaMls: true, - dbEncryptionKey: new Uint8Array([ - 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, - 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, - 145, - ]), - }) - await client.conversations.syncGroups() + await delayToPropogate() + await new Promise((resolve) => setTimeout(resolve, 10000)) + assert(groupCallbacks === 1, 'group stream should have received 1 group') // <--- Fails here assert( - (await client.conversations.listGroups()).length === 0, - `should have a group size of 0 but was ${ - (await client.conversations.listGroups()).length - }` + messageCallbacks === 1, + 'message stream should have received 1 message' ) - return true }) -test('can make a MLS V3 client with encryption key and database directory', async () => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const dbDirPath = `${RNFS.DocumentDirectoryPath}/xmtp_db` - const directoryExists = await RNFS.exists(dbDirPath) - if (!directoryExists) { - await RNFS.mkdir(dbDirPath) - } - const key = new Uint8Array([ - 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, - 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, - ]) - - const client = await Client.createRandom({ - env: 'local', - appVersion: 'Testing/0.0.0', - enableAlphaMls: true, - dbEncryptionKey: key, - dbDirectory: dbDirPath, - }) +// test('can make a MLS V3 client', async () => { +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// const client = await Client.createRandom({ +// env: 'local', +// appVersion: 'Testing/0.0.0', +// enableAlphaMls: true, +// }) - const anotherClient = await Client.createRandom({ - env: 'local', - appVersion: 'Testing/0.0.0', - enableAlphaMls: true, - dbEncryptionKey: key, - }) +// return true +// }) - await client.conversations.newGroup([anotherClient.address]) - assert( - (await client.conversations.listGroups()).length === 1, - `should have a group size of 1 but was ${ - (await client.conversations.listGroups()).length - }` - ) +// test('can delete a local database', async () => { +// let [client, anotherClient] = await createClients(2) + +// await client.conversations.newGroup([anotherClient.address]) +// await client.conversations.syncGroups() +// assert( +// (await client.conversations.listGroups()).length === 1, +// `should have a group size of 1 but was ${ +// (await client.conversations.listGroups()).length +// }` +// ) + +// await client.deleteLocalDatabase() +// client = await Client.createRandom({ +// env: 'local', +// appVersion: 'Testing/0.0.0', +// enableAlphaMls: true, +// dbEncryptionKey: new Uint8Array([ +// 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, +// 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, +// 145, +// ]), +// }) +// await client.conversations.syncGroups() +// assert( +// (await client.conversations.listGroups()).length === 0, +// `should have a group size of 0 but was ${ +// (await client.conversations.listGroups()).length +// }` +// ) - const bundle = await client.exportKeyBundle() - const clientFromBundle = await Client.createFromKeyBundle(bundle, { - env: 'local', - appVersion: 'Testing/0.0.0', - enableAlphaMls: true, - dbEncryptionKey: key, - dbDirectory: dbDirPath, - }) +// return true +// }) - assert( - clientFromBundle.address === client.address, - `clients dont match ${client.address} and ${clientFromBundle.address}` - ) +// test('can make a MLS V3 client with encryption key and database directory', async () => { +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// const dbDirPath = `${RNFS.DocumentDirectoryPath}/xmtp_db` +// const directoryExists = await RNFS.exists(dbDirPath) +// if (!directoryExists) { +// await RNFS.mkdir(dbDirPath) +// } +// const key = new Uint8Array([ +// 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, +// 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, +// ]) + +// const client = await Client.createRandom({ +// env: 'local', +// appVersion: 'Testing/0.0.0', +// enableAlphaMls: true, +// dbEncryptionKey: key, +// dbDirectory: dbDirPath, +// }) + +// const anotherClient = await Client.createRandom({ +// env: 'local', +// appVersion: 'Testing/0.0.0', +// enableAlphaMls: true, +// dbEncryptionKey: key, +// }) + +// await client.conversations.newGroup([anotherClient.address]) +// assert( +// (await client.conversations.listGroups()).length === 1, +// `should have a group size of 1 but was ${ +// (await client.conversations.listGroups()).length +// }` +// ) + +// const bundle = await client.exportKeyBundle() +// const clientFromBundle = await Client.createFromKeyBundle(bundle, { +// env: 'local', +// appVersion: 'Testing/0.0.0', +// enableAlphaMls: true, +// dbEncryptionKey: key, +// dbDirectory: dbDirPath, +// }) + +// assert( +// clientFromBundle.address === client.address, +// `clients dont match ${client.address} and ${clientFromBundle.address}` +// ) + +// assert( +// (await clientFromBundle.conversations.listGroups()).length === 1, +// `should have a group size of 1 but was ${ +// (await clientFromBundle.conversations.listGroups()).length +// }` +// ) +// return true +// }) - assert( - (await clientFromBundle.conversations.listGroups()).length === 1, - `should have a group size of 1 but was ${ - (await clientFromBundle.conversations.listGroups()).length - }` - ) - return true -}) +// test('can drop a local database', async () => { +// const [client, anotherClient] = await createClients(2) + +// const group = await client.conversations.newGroup([anotherClient.address]) +// await client.conversations.syncGroups() +// assert( +// (await client.conversations.listGroups()).length === 1, +// `should have a group size of 1 but was ${ +// (await client.conversations.listGroups()).length +// }` +// ) + +// await client.dropLocalDatabaseConnection() + +// try { +// await group.send('hi') +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// } catch (error) { +// await client.reconnectLocalDatabase() +// await group.send('hi') +// return true +// } +// throw new Error('should throw when local database not connected') +// }) -test('can drop a local database', async () => { - const [client, anotherClient] = await createClients(2) +// test('can make a MLS V3 client from bundle', async () => { +// const key = new Uint8Array([ +// 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, +// 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, +// ]) + +// const client = await Client.createRandom({ +// env: 'local', +// appVersion: 'Testing/0.0.0', +// enableAlphaMls: true, +// dbEncryptionKey: key, +// }) + +// const anotherClient = await Client.createRandom({ +// env: 'local', +// appVersion: 'Testing/0.0.0', +// enableAlphaMls: true, +// dbEncryptionKey: key, +// }) + +// const group1 = await client.conversations.newGroup([anotherClient.address]) + +// assert( +// group1.client.address === client.address, +// `clients dont match ${client.address} and ${group1.client.address}` +// ) + +// const bundle = await client.exportKeyBundle() +// const client2 = await Client.createFromKeyBundle(bundle, { +// env: 'local', +// appVersion: 'Testing/0.0.0', +// enableAlphaMls: true, +// dbEncryptionKey: key, +// }) + +// assert( +// client.address === client2.address, +// `clients dont match ${client2.address} and ${client.address}` +// ) + +// assert( +// client.inboxId === client2.inboxId, +// `clients dont match ${client2.inboxId} and ${client.inboxId}` +// ) + +// assert( +// client.installationId === client2.installationId, +// `clients dont match ${client2.installationId} and ${client.installationId}` +// ) + +// const randomClient = await Client.createRandom({ +// env: 'local', +// appVersion: 'Testing/0.0.0', +// enableAlphaMls: true, +// dbEncryptionKey: key, +// }) + +// const group = await client2.conversations.newGroup([randomClient.address]) + +// assert( +// group.client.address === client2.address, +// `clients dont match ${client2.address} and ${group.client.address}` +// ) - const group = await client.conversations.newGroup([anotherClient.address]) - await client.conversations.syncGroups() - assert( - (await client.conversations.listGroups()).length === 1, - `should have a group size of 1 but was ${ - (await client.conversations.listGroups()).length - }` - ) +// return true +// }) - await client.dropLocalDatabaseConnection() - - try { - await group.send('hi') - // eslint-disable-next-line @typescript-eslint/no-unused-vars - } catch (error) { - await client.reconnectLocalDatabase() - await group.send('hi') - return true - } - throw new Error('should throw when local database not connected') -}) +// test('production MLS V3 client creation throws error', async () => { +// const key = new Uint8Array([ +// 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, +// 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, +// ]) + +// try { +// await Client.createRandom({ +// env: 'production', +// appVersion: 'Testing/0.0.0', +// enableAlphaMls: true, +// dbEncryptionKey: key, +// }) +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// } catch (error) { +// return true +// } +// throw new Error( +// 'should throw error on MLS V3 client create when environment is not local' +// ) +// }) -test('can make a MLS V3 client from bundle', async () => { - const key = new Uint8Array([ - 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, - 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, - ]) - - const client = await Client.createRandom({ - env: 'local', - appVersion: 'Testing/0.0.0', - enableAlphaMls: true, - dbEncryptionKey: key, - }) +// test('group message delivery status', async () => { +// const [alixClient, boClient] = await createClients(2) +// const alixGroup = await alixClient.conversations.newGroup([boClient.address]) - const anotherClient = await Client.createRandom({ - env: 'local', - appVersion: 'Testing/0.0.0', - enableAlphaMls: true, - dbEncryptionKey: key, - }) +// await alixGroup.send('hello, world') - const group1 = await client.conversations.newGroup([anotherClient.address]) +// const alixMessages: DecodedMessage[] = await alixGroup.messages() - assert( - group1.client.address === client.address, - `clients dont match ${client.address} and ${group1.client.address}` - ) +// assert( +// alixMessages.length === 2, +// `the messages length should be 2 but was ${alixMessages.length}` +// ) - const bundle = await client.exportKeyBundle() - const client2 = await Client.createFromKeyBundle(bundle, { - env: 'local', - appVersion: 'Testing/0.0.0', - enableAlphaMls: true, - dbEncryptionKey: key, - }) +// const alixMessagesFiltered: DecodedMessage[] = await alixGroup.messages({ +// deliveryStatus: MessageDeliveryStatus.UNPUBLISHED, +// }) - assert( - client.address === client2.address, - `clients dont match ${client2.address} and ${client.address}` - ) +// assert( +// alixMessagesFiltered.length === 1, +// `the messages length should be 1 but was ${alixMessagesFiltered.length}` +// ) - assert( - client.inboxId === client2.inboxId, - `clients dont match ${client2.inboxId} and ${client.inboxId}` - ) +// await alixGroup.sync() +// const alixMessages2: DecodedMessage[] = await alixGroup.messages() - assert( - client.installationId === client2.installationId, - `clients dont match ${client2.installationId} and ${client.installationId}` - ) +// assert( +// alixMessages2.length === 2, +// `the messages length should be 2 but was ${alixMessages.length}` +// ) - const randomClient = await Client.createRandom({ - env: 'local', - appVersion: 'Testing/0.0.0', - enableAlphaMls: true, - dbEncryptionKey: key, - }) +// assert( +// alixMessages2[0].deliveryStatus === 'PUBLISHED', +// `the message should have a delivery status of PUBLISHED but was ${alixMessages2[0].deliveryStatus}` +// ) - const group = await client2.conversations.newGroup([randomClient.address]) +// await boClient.conversations.syncGroups() +// const boGroup = (await boClient.conversations.listGroups())[0] +// await boGroup.sync() +// const boMessages: DecodedMessage[] = await boGroup.messages() - assert( - group.client.address === client2.address, - `clients dont match ${client2.address} and ${group.client.address}` - ) +// assert( +// boMessages.length === 1, +// `the messages length should be 1 but was ${boMessages.length}` +// ) - return true -}) +// assert( +// boMessages[0].deliveryStatus === 'PUBLISHED', +// `the message should have a delivery status of PUBLISHED but was ${boMessages[0].deliveryStatus}` +// ) -test('production MLS V3 client creation throws error', async () => { - const key = new Uint8Array([ - 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, - 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, - ]) - - try { - await Client.createRandom({ - env: 'production', - appVersion: 'Testing/0.0.0', - enableAlphaMls: true, - dbEncryptionKey: key, - }) - // eslint-disable-next-line @typescript-eslint/no-unused-vars - } catch (error) { - return true - } - throw new Error( - 'should throw error on MLS V3 client create when environment is not local' - ) -}) +// return true +// }) -test('group message delivery status', async () => { - const [alixClient, boClient] = await createClients(2) - const alixGroup = await alixClient.conversations.newGroup([boClient.address]) +// test('who added me to a group', async () => { +// const [alixClient, boClient] = await createClients(2) +// await alixClient.conversations.newGroup([boClient.address]) - await alixGroup.send('hello, world') +// await boClient.conversations.syncGroups() +// const boGroup = (await boClient.conversations.listGroups())[0] +// const addedByInboxId = await boGroup.addedByInboxId() - const alixMessages: DecodedMessage[] = await alixGroup.messages() +// assert( +// addedByInboxId === alixClient.inboxId, +// `addedByInboxId ${addedByInboxId} does not match ${alixClient.inboxId}` +// ) +// return true +// }) - assert( - alixMessages.length === 2, - `the messages length should be 2 but was ${alixMessages.length}` - ) +// test('can get members of a group', async () => { +// const [alixClient, boClient] = await createClients(2) +// const group = await alixClient.conversations.newGroup([boClient.address]) + +// const members = await group.members() + +// assert(members.length === 2, `Should be 2 members but was ${members.length}`) + +// // We can not be sure of the order that members will be returned in +// for (const member of members) { +// // Alix created the group so they are a super admin +// if ( +// member.addresses[0].toLocaleLowerCase() === +// alixClient.address.toLocaleLowerCase() +// ) { +// assert( +// member.permissionLevel === 'super_admin', +// `Should be super_admin but was ${member.permissionLevel}` +// ) +// } +// // Bo did not create the group so he defaults to permission level "member" +// if ( +// member.addresses[0].toLocaleLowerCase() === +// boClient.address.toLocaleLowerCase() +// ) { +// assert( +// member.permissionLevel === 'member', +// `Should be member but was ${member.permissionLevel}` +// ) +// } +// } +// return true +// }) - const alixMessagesFiltered: DecodedMessage[] = await alixGroup.messages({ - deliveryStatus: MessageDeliveryStatus.UNPUBLISHED, - }) +// test('can message in a group', async () => { +// // Create three MLS enabled Clients +// const [alixClient, boClient, caroClient] = await createClients(3) - assert( - alixMessagesFiltered.length === 1, - `the messages length should be 1 but was ${alixMessagesFiltered.length}` - ) +// // alix's num groups start at 0 +// let alixGroups = await alixClient.conversations.listGroups() +// if (alixGroups.length !== 0) { +// throw new Error('num groups should be 0') +// } - await alixGroup.sync() - const alixMessages2: DecodedMessage[] = await alixGroup.messages() +// // alix creates a group +// const alixGroup = await alixClient.conversations.newGroup([ +// boClient.address, +// caroClient.address, +// ]) + +// // alix's num groups == 1 +// await alixClient.conversations.syncGroups() +// alixGroups = await alixClient.conversations.listGroups() +// if (alixGroups.length !== 1) { +// throw new Error('num groups should be 1') +// } - assert( - alixMessages2.length === 2, - `the messages length should be 2 but was ${alixMessages.length}` - ) +// // alix group should match create time from list function +// assert(alixGroups[0].createdAt === alixGroup.createdAt, 'group create time') - assert( - alixMessages2[0].deliveryStatus === 'PUBLISHED', - `the message should have a delivery status of PUBLISHED but was ${alixMessages2[0].deliveryStatus}` - ) +// // alix can confirm memberInboxIds +// await alixGroup.sync() +// const memberInboxIds = await alixGroup.memberInboxIds() +// if (memberInboxIds.length !== 3) { +// throw new Error('num group members should be 3') +// } +// const peerInboxIds = await alixGroup.peerInboxIds +// if (peerInboxIds.length !== 2) { +// throw new Error('num peer group members should be 2') +// } +// if ( +// !( +// memberInboxIds.includes(alixClient.inboxId) && +// memberInboxIds.includes(boClient.inboxId) && +// memberInboxIds.includes(caroClient.inboxId) +// ) +// ) { +// throw new Error('missing address') +// } - await boClient.conversations.syncGroups() - const boGroup = (await boClient.conversations.listGroups())[0] - await boGroup.sync() - const boMessages: DecodedMessage[] = await boGroup.messages() +// if ( +// !( +// peerInboxIds.includes(boClient.inboxId) && +// peerInboxIds.includes(caroClient.inboxId) +// ) +// ) { +// throw new Error('should include self') +// } - assert( - boMessages.length === 1, - `the messages length should be 1 but was ${boMessages.length}` - ) +// // alix can send messages +// await alixGroup.send('hello, world') +// await alixGroup.send('gm') + +// // bo's num groups == 1 +// await boClient.conversations.syncGroups() +// const boGroups = await boClient.conversations.listGroups() +// if (boGroups.length !== 1) { +// throw new Error( +// 'num groups for bo should be 1, but it is' + boGroups.length +// ) +// } +// await delayToPropogate() +// // bo can read messages from alix +// await boGroups[0].sync() +// const boMessages: DecodedMessage[] = await boGroups[0].messages() + +// if (boMessages.length !== 2) { +// throw new Error( +// 'num messages for bo should be 2, but it is' + boMessages.length +// ) +// } +// if (boMessages[0].content() !== 'gm') { +// throw new Error("newest message should be 'gm'") +// } +// if (boMessages[1].content() !== 'hello, world') { +// throw new Error("newest message should be 'hello, world'") +// } +// // bo can send a message +// await boGroups[0].send('hey guys!') + +// // caro's num groups == 1 +// await caroClient.conversations.syncGroups() +// const caroGroups = await caroClient.conversations.listGroups() +// if (caroGroups.length !== 1) { +// throw new Error( +// 'num groups for caro should be 1, but it is' + caroGroups.length +// ) +// } - assert( - boMessages[0].deliveryStatus === 'PUBLISHED', - `the message should have a delivery status of PUBLISHED but was ${boMessages[0].deliveryStatus}` - ) +// // caro can read messages from alix and bo +// await caroGroups[0].sync() +// const caroMessages = await caroGroups[0].messages() - return true -}) +// if (caroMessages.length !== 3) { +// throw new Error(`length should be 3 but was ${caroMessages.length}`) +// } +// if (caroMessages[0].content() !== 'hey guys!') { +// throw new Error( +// `newest Message should be 'hey guys!' but was ${caroMessages[0].content()}` +// ) +// } +// if (caroMessages[1].content() !== 'gm') { +// throw new Error( +// `second Message should be 'gm' but was ${caroMessages[1].content()}` +// ) +// } -test('who added me to a group', async () => { - const [alixClient, boClient] = await createClients(2) - await alixClient.conversations.newGroup([boClient.address]) +// return true +// }) - await boClient.conversations.syncGroups() - const boGroup = (await boClient.conversations.listGroups())[0] - const addedByInboxId = await boGroup.addedByInboxId() +// test('can add members to a group', async () => { +// // Create three MLS enabled Clients +// const [alixClient, boClient, caroClient] = await createClients(3) - assert( - addedByInboxId === alixClient.inboxId, - `addedByInboxId ${addedByInboxId} does not match ${alixClient.inboxId}` - ) - return true -}) +// // alix's num groups start at 0 +// let alixGroups = await alixClient.conversations.listGroups() +// if (alixGroups.length !== 0) { +// throw new Error('num groups should be 0') +// } -test('can get members of a group', async () => { - const [alixClient, boClient] = await createClients(2) - const group = await alixClient.conversations.newGroup([boClient.address]) - - const members = await group.members() - - assert(members.length === 2, `Should be 2 members but was ${members.length}`) - - // We can not be sure of the order that members will be returned in - for (const member of members) { - // Alix created the group so they are a super admin - if ( - member.addresses[0].toLocaleLowerCase() === - alixClient.address.toLocaleLowerCase() - ) { - assert( - member.permissionLevel === 'super_admin', - `Should be super_admin but was ${member.permissionLevel}` - ) - } - // Bo did not create the group so he defaults to permission level "member" - if ( - member.addresses[0].toLocaleLowerCase() === - boClient.address.toLocaleLowerCase() - ) { - assert( - member.permissionLevel === 'member', - `Should be member but was ${member.permissionLevel}` - ) - } - } - return true -}) +// // bo's num groups start at 0 +// let boGroups = await boClient.conversations.listGroups() +// if (boGroups.length !== 0) { +// throw new Error('num groups should be 0') +// } -test('can message in a group', async () => { - // Create three MLS enabled Clients - const [alixClient, boClient, caroClient] = await createClients(3) - - // alix's num groups start at 0 - let alixGroups = await alixClient.conversations.listGroups() - if (alixGroups.length !== 0) { - throw new Error('num groups should be 0') - } - - // alix creates a group - const alixGroup = await alixClient.conversations.newGroup([ - boClient.address, - caroClient.address, - ]) - - // alix's num groups == 1 - await alixClient.conversations.syncGroups() - alixGroups = await alixClient.conversations.listGroups() - if (alixGroups.length !== 1) { - throw new Error('num groups should be 1') - } - - // alix group should match create time from list function - assert(alixGroups[0].createdAt === alixGroup.createdAt, 'group create time') - - // alix can confirm memberInboxIds - await alixGroup.sync() - const memberInboxIds = await alixGroup.memberInboxIds() - if (memberInboxIds.length !== 3) { - throw new Error('num group members should be 3') - } - const peerInboxIds = await alixGroup.peerInboxIds - if (peerInboxIds.length !== 2) { - throw new Error('num peer group members should be 2') - } - if ( - !( - memberInboxIds.includes(alixClient.inboxId) && - memberInboxIds.includes(boClient.inboxId) && - memberInboxIds.includes(caroClient.inboxId) - ) - ) { - throw new Error('missing address') - } - - if ( - !( - peerInboxIds.includes(boClient.inboxId) && - peerInboxIds.includes(caroClient.inboxId) - ) - ) { - throw new Error('should include self') - } - - // alix can send messages - await alixGroup.send('hello, world') - await alixGroup.send('gm') - - // bo's num groups == 1 - await boClient.conversations.syncGroups() - const boGroups = await boClient.conversations.listGroups() - if (boGroups.length !== 1) { - throw new Error( - 'num groups for bo should be 1, but it is' + boGroups.length - ) - } - await delayToPropogate() - // bo can read messages from alix - await boGroups[0].sync() - const boMessages: DecodedMessage[] = await boGroups[0].messages() - - if (boMessages.length !== 2) { - throw new Error( - 'num messages for bo should be 2, but it is' + boMessages.length - ) - } - if (boMessages[0].content() !== 'gm') { - throw new Error("newest message should be 'gm'") - } - if (boMessages[1].content() !== 'hello, world') { - throw new Error("newest message should be 'hello, world'") - } - // bo can send a message - await boGroups[0].send('hey guys!') - - // caro's num groups == 1 - await caroClient.conversations.syncGroups() - const caroGroups = await caroClient.conversations.listGroups() - if (caroGroups.length !== 1) { - throw new Error( - 'num groups for caro should be 1, but it is' + caroGroups.length - ) - } - - // caro can read messages from alix and bo - await caroGroups[0].sync() - const caroMessages = await caroGroups[0].messages() - - if (caroMessages.length !== 3) { - throw new Error(`length should be 3 but was ${caroMessages.length}`) - } - if (caroMessages[0].content() !== 'hey guys!') { - throw new Error( - `newest Message should be 'hey guys!' but was ${caroMessages[0].content()}` - ) - } - if (caroMessages[1].content() !== 'gm') { - throw new Error( - `second Message should be 'gm' but was ${caroMessages[1].content()}` - ) - } +// // caro's num groups start at 0 +// let caroGroups = await caroClient.conversations.listGroups() +// if (caroGroups.length !== 0) { +// throw new Error('num groups should be 0') +// } - return true -}) +// // alix creates a group +// const alixGroup = await alixClient.conversations.newGroup([boClient.address]) -test('can add members to a group', async () => { - // Create three MLS enabled Clients - const [alixClient, boClient, caroClient] = await createClients(3) - - // alix's num groups start at 0 - let alixGroups = await alixClient.conversations.listGroups() - if (alixGroups.length !== 0) { - throw new Error('num groups should be 0') - } - - // bo's num groups start at 0 - let boGroups = await boClient.conversations.listGroups() - if (boGroups.length !== 0) { - throw new Error('num groups should be 0') - } - - // caro's num groups start at 0 - let caroGroups = await caroClient.conversations.listGroups() - if (caroGroups.length !== 0) { - throw new Error('num groups should be 0') - } - - // alix creates a group - const alixGroup = await alixClient.conversations.newGroup([boClient.address]) - - // alix's num groups == 1 - await alixClient.conversations.syncGroups() - alixGroups = await alixClient.conversations.listGroups() - if (alixGroups.length !== 1) { - throw new Error('num groups should be 1') - } - - // alix can confirm memberInboxIds - await alixGroup.sync() - const memberInboxIds = await alixGroup.memberInboxIds() - if (memberInboxIds.length !== 2) { - throw new Error('num group members should be 2') - } - if ( - !( - memberInboxIds.includes(alixClient.inboxId) && - memberInboxIds.includes(boClient.inboxId) - ) - ) { - throw new Error('missing address') - } - - // alix can send messages - await alixGroup.send('hello, world') - await alixGroup.send('gm') - - // bo's num groups == 1 - await boClient.conversations.syncGroups() - boGroups = await boClient.conversations.listGroups() - if (boGroups.length !== 1) { - throw new Error( - 'num groups for bo should be 1, but it is' + boGroups.length - ) - } - - await alixGroup.addMembers([caroClient.address]) - - // caro's num groups == 1 - await caroClient.conversations.syncGroups() - caroGroups = await caroClient.conversations.listGroups() - if (caroGroups.length !== 1) { - throw new Error( - 'num groups for caro should be 1, but it is' + caroGroups.length - ) - } - await caroGroups[0].sync() - const caroMessages = await caroGroups[0].messages() - if (caroMessages.length !== 0) { - throw new Error('num messages for caro should be 0') - } - - await boGroups[0].sync() - const boGroupMembers = await boGroups[0].memberInboxIds() - if (boGroupMembers.length !== 3) { - throw new Error('num group members should be 3') - } +// // alix's num groups == 1 +// await alixClient.conversations.syncGroups() +// alixGroups = await alixClient.conversations.listGroups() +// if (alixGroups.length !== 1) { +// throw new Error('num groups should be 1') +// } - return true -}) +// // alix can confirm memberInboxIds +// await alixGroup.sync() +// const memberInboxIds = await alixGroup.memberInboxIds() +// if (memberInboxIds.length !== 2) { +// throw new Error('num group members should be 2') +// } +// if ( +// !( +// memberInboxIds.includes(alixClient.inboxId) && +// memberInboxIds.includes(boClient.inboxId) +// ) +// ) { +// throw new Error('missing address') +// } -test('can remove members from a group', async () => { - // Create three MLS enabled Clients - const [alixClient, boClient, caroClient] = await createClients(3) - - // alix's num groups start at 0 - let alixGroups = await alixClient.conversations.listGroups() - if (alixGroups.length !== 0) { - throw new Error('num groups should be 0') - } - - // bo's num groups start at 0 - let boGroups = await boClient.conversations.listGroups() - assert(boGroups.length === 0, 'num groups should be 0') - - // caro's num groups start at 0 - let caroGroups = await caroClient.conversations.listGroups() - if (caroGroups.length !== 0) { - throw new Error('num groups should be 0') - } - - // alix creates a group - const alixGroup = await alixClient.conversations.newGroup([ - boClient.address, - caroClient.address, - ]) - - // alix's num groups == 1 - await alixClient.conversations.syncGroups() - alixGroups = await alixClient.conversations.listGroups() - if (alixGroups.length !== 1) { - throw new Error('num groups should be 1') - } - - // alix can confirm memberInboxIds - await alixGroup.sync() - const memberInboxIds = await alixGroup.memberInboxIds() - if (memberInboxIds.length !== 3) { - throw new Error('num group members should be 3') - } - if ( - !( - memberInboxIds.includes(alixClient.inboxId) && - memberInboxIds.includes(boClient.inboxId) - ) - ) { - throw new Error('missing address') - } - - // alix can send messages - await alixGroup.send('hello, world') - await alixGroup.send('gm') - - // bo's num groups == 1 - await boClient.conversations.syncGroups() - boGroups = await boClient.conversations.listGroups() - if (boGroups.length !== 1) { - throw new Error( - 'num groups for bo should be 1, but it is' + boGroups.length - ) - } - - // caro's num groups == 1 - await caroClient.conversations.syncGroups() - caroGroups = await caroClient.conversations.listGroups() - if (caroGroups.length !== 1) { - throw new Error( - 'num groups for caro should be 1, but it is' + caroGroups.length - ) - } - - await caroGroups[0].sync() - if (!caroGroups[0].isActive()) { - throw new Error('caros group should be active') - } - - await alixGroup.removeMembers([caroClient.address]) - await alixGroup.sync() - const alixGroupMembers = await alixGroup.memberInboxIds() - if (alixGroupMembers.length !== 2) { - throw new Error( - 'num group members should be 2 but was' + alixGroupMembers.length - ) - } - - await caroGroups[0].sync() - if (await caroGroups[0].isActive()) { - throw new Error('caros group should not be active') - } - - const caroGroupMembers = await caroGroups[0].memberInboxIds() - // should be 3 since they wont get new updates to the group after being removed - if (caroGroupMembers.length !== 3) { - throw new Error( - 'num group members should be 3 but was' + caroGroupMembers.length - ) - } +// // alix can send messages +// await alixGroup.send('hello, world') +// await alixGroup.send('gm') + +// // bo's num groups == 1 +// await boClient.conversations.syncGroups() +// boGroups = await boClient.conversations.listGroups() +// if (boGroups.length !== 1) { +// throw new Error( +// 'num groups for bo should be 1, but it is' + boGroups.length +// ) +// } - return true -}) +// await alixGroup.addMembers([caroClient.address]) -test('can remove and add members from a group by inbox id', async () => { - // Create three MLS enabled Clients - const [alixClient, boClient, caroClient] = await createClients(3) - - // alix creates a group - const alixGroup = await alixClient.conversations.newGroup([ - boClient.address, - caroClient.address, - ]) - - // alix can confirm memberInboxIds - await alixGroup.sync() - const memberInboxIds = await alixGroup.memberInboxIds() - if (memberInboxIds.length !== 3) { - throw new Error('num group members should be 3') - } - - await alixGroup.removeMembersByInboxId([caroClient.inboxId]) - await alixGroup.sync() - const alixGroupMembers = await alixGroup.memberInboxIds() - if (alixGroupMembers.length !== 2) { - throw new Error('num group members should be 2') - } - - await alixGroup.addMembersByInboxId([caroClient.inboxId]) - await alixGroup.sync() - const alixGroupMembers2 = await alixGroup.memberInboxIds() - if (alixGroupMembers2.length !== 3) { - throw new Error('num group members should be 3') - } +// // caro's num groups == 1 +// await caroClient.conversations.syncGroups() +// caroGroups = await caroClient.conversations.listGroups() +// if (caroGroups.length !== 1) { +// throw new Error( +// 'num groups for caro should be 1, but it is' + caroGroups.length +// ) +// } +// await caroGroups[0].sync() +// const caroMessages = await caroGroups[0].messages() +// if (caroMessages.length !== 0) { +// throw new Error('num messages for caro should be 0') +// } - return true -}) +// await boGroups[0].sync() +// const boGroupMembers = await boGroups[0].memberInboxIds() +// if (boGroupMembers.length !== 3) { +// throw new Error('num group members should be 3') +// } -test('can stream groups', async () => { - const [alixClient, boClient, caroClient] = await createClients(3) +// return true +// }) - // Start streaming groups - const groups: Group[] = [] - const cancelStreamGroups = await alixClient.conversations.streamGroups( - async (group: Group) => { - groups.push(group) - } - ) +// test('can remove members from a group', async () => { +// // Create three MLS enabled Clients +// const [alixClient, boClient, caroClient] = await createClients(3) - // caro creates a group with alix, so stream callback is fired - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const caroGroup = await caroClient.conversations.newGroup([ - alixClient.address, - ]) - await delayToPropogate() - if ((groups.length as number) !== 1) { - throw Error('Unexpected num groups (should be 1): ' + groups.length) - } +// // alix's num groups start at 0 +// let alixGroups = await alixClient.conversations.listGroups() +// if (alixGroups.length !== 0) { +// throw new Error('num groups should be 0') +// } - // bo creates a group with alix so a stream callback is fired - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const boGroup = await boClient.conversations.newGroup([alixClient.address]) - await delayToPropogate() - if ((groups.length as number) !== 2) { - throw Error('Unexpected num groups (should be 2): ' + groups.length) - } - - // * Note alix creating a group does not trigger alix conversations - // group stream. Workaround is to syncGroups after you create and list manually - // See https://github.com/xmtp/libxmtp/issues/504 - - // alix creates a group - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const alixGroup = await alixClient.conversations.newGroup([ - boClient.address, - caroClient.address, - ]) - await delayToPropogate() - if (groups.length !== 2) { - throw Error('Expected group length 2 but it is: ' + groups.length) - } - // Sync groups after creation if you created a group - const listedGroups = await alixClient.conversations.listGroups() - await delayToPropogate() - groups.push(listedGroups[listedGroups.length - 1]) - if ((groups.length as number) !== 3) { - throw Error('Expected group length 3 but it is: ' + groups.length) - } +// // bo's num groups start at 0 +// let boGroups = await boClient.conversations.listGroups() +// assert(boGroups.length === 0, 'num groups should be 0') - cancelStreamGroups() - await delayToPropogate() +// // caro's num groups start at 0 +// let caroGroups = await caroClient.conversations.listGroups() +// if (caroGroups.length !== 0) { +// throw new Error('num groups should be 0') +// } - // Creating a group should no longer trigger stream groups - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const caroSecond = await caroClient.conversations.newGroup([ - alixClient.address, - ]) - await delayToPropogate() - if ((groups.length as number) !== 3) { - throw Error('Unexpected num groups (should be 3): ' + groups.length) - } +// // alix creates a group +// const alixGroup = await alixClient.conversations.newGroup([ +// boClient.address, +// caroClient.address, +// ]) + +// // alix's num groups == 1 +// await alixClient.conversations.syncGroups() +// alixGroups = await alixClient.conversations.listGroups() +// if (alixGroups.length !== 1) { +// throw new Error('num groups should be 1') +// } - return true -}) +// // alix can confirm memberInboxIds +// await alixGroup.sync() +// const memberInboxIds = await alixGroup.memberInboxIds() +// if (memberInboxIds.length !== 3) { +// throw new Error('num group members should be 3') +// } +// if ( +// !( +// memberInboxIds.includes(alixClient.inboxId) && +// memberInboxIds.includes(boClient.inboxId) +// ) +// ) { +// throw new Error('missing address') +// } -test('can list all groups and conversations', async () => { - const [alixClient, boClient, caroClient] = await createClients(3) +// // alix can send messages +// await alixGroup.send('hello, world') +// await alixGroup.send('gm') + +// // bo's num groups == 1 +// await boClient.conversations.syncGroups() +// boGroups = await boClient.conversations.listGroups() +// if (boGroups.length !== 1) { +// throw new Error( +// 'num groups for bo should be 1, but it is' + boGroups.length +// ) +// } - // Add one group and one conversation - const boGroup = await boClient.conversations.newGroup([alixClient.address]) - const alixConversation = await alixClient.conversations.newConversation( - caroClient.address - ) +// // caro's num groups == 1 +// await caroClient.conversations.syncGroups() +// caroGroups = await caroClient.conversations.listGroups() +// if (caroGroups.length !== 1) { +// throw new Error( +// 'num groups for caro should be 1, but it is' + caroGroups.length +// ) +// } - const listedContainers = await alixClient.conversations.listAll() - - // Verify information in listed containers is correct - // BUG - List All returns in Chronological order on iOS - // and reverse Chronological order on Android - const first = isIos() ? 1 : 0 - const second = isIos() ? 0 : 1 - if ( - listedContainers[first].topic !== boGroup.topic || - listedContainers[first].version !== ConversationVersion.GROUP || - listedContainers[second].version !== ConversationVersion.DIRECT || - listedContainers[second].createdAt !== alixConversation.createdAt - ) { - throw Error('Listed containers should match streamed containers') - } +// await caroGroups[0].sync() +// if (!caroGroups[0].isActive()) { +// throw new Error('caros group should be active') +// } - return true -}) +// await alixGroup.removeMembers([caroClient.address]) +// await alixGroup.sync() +// const alixGroupMembers = await alixGroup.memberInboxIds() +// if (alixGroupMembers.length !== 2) { +// throw new Error( +// 'num group members should be 2 but was' + alixGroupMembers.length +// ) +// } -test('can stream all groups and conversations', async () => { - const [alixClient, boClient, caroClient] = await createClients(3) +// await caroGroups[0].sync() +// if (await caroGroups[0].isActive()) { +// throw new Error('caros group should not be active') +// } - // Start streaming groups and conversations - const containers: ConversationContainer[] = [] - const cancelStreamAll = await alixClient.conversations.streamAll( - async (conversationContainer: ConversationContainer) => { - containers.push(conversationContainer) - } - ) +// const caroGroupMembers = await caroGroups[0].memberInboxIds() +// // should be 3 since they wont get new updates to the group after being removed +// if (caroGroupMembers.length !== 3) { +// throw new Error( +// 'num group members should be 3 but was' + caroGroupMembers.length +// ) +// } - // bo creates a group with alix, so stream callback is fired - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const boGroup = await boClient.conversations.newGroup([alixClient.address]) - await delayToPropogate() - if ((containers.length as number) !== 1) { - throw Error('Unexpected num groups (should be 1): ' + containers.length) - } - - // bo creates a v2 Conversation with alix so a stream callback is fired - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const boConversation = await boClient.conversations.newConversation( - alixClient.address - ) - await delayToPropogate() - if ((containers.length as number) !== 2) { - throw Error('Unexpected num groups (should be 2): ' + containers.length) - } - - if ( - containers[1].version === ConversationVersion.DIRECT && - boConversation.conversationID !== - (containers[1] as Conversation).conversationID - ) { - throw Error( - 'Conversation from streamed all should match conversationID with created conversation' - ) - } - - // * Note alix creating a v2 Conversation does trigger alix conversations - // stream. - - // alix creates a V2 Conversationgroup - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const alixConversation = await alixClient.conversations.newConversation( - caroClient.address - ) - await delayToPropogate() - if (containers.length !== 3) { - throw Error('Expected group length 3 but it is: ' + containers.length) - } +// return true +// }) - cancelStreamAll() - await delayToPropogate() +// test('can remove and add members from a group by inbox id', async () => { +// // Create three MLS enabled Clients +// const [alixClient, boClient, caroClient] = await createClients(3) + +// // alix creates a group +// const alixGroup = await alixClient.conversations.newGroup([ +// boClient.address, +// caroClient.address, +// ]) + +// // alix can confirm memberInboxIds +// await alixGroup.sync() +// const memberInboxIds = await alixGroup.memberInboxIds() +// if (memberInboxIds.length !== 3) { +// throw new Error('num group members should be 3') +// } - // Creating a group should no longer trigger stream groups - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const caroConversation = await caroClient.conversations.newGroup([ - alixClient.address, - ]) - await delayToPropogate() - if ((containers.length as number) !== 3) { - throw Error('Unexpected num groups (should be 3): ' + containers.length) - } +// await alixGroup.removeMembersByInboxId([caroClient.inboxId]) +// await alixGroup.sync() +// const alixGroupMembers = await alixGroup.memberInboxIds() +// if (alixGroupMembers.length !== 2) { +// throw new Error('num group members should be 2') +// } - return true -}) +// await alixGroup.addMembersByInboxId([caroClient.inboxId]) +// await alixGroup.sync() +// const alixGroupMembers2 = await alixGroup.memberInboxIds() +// if (alixGroupMembers2.length !== 3) { +// throw new Error('num group members should be 3') +// } -test('canMessage', async () => { - const [bo, alix, caro] = await createClients(3) +// return true +// }) - const canMessage = await bo.canMessage(alix.address) - if (!canMessage) { - throw new Error('should be able to message v2 client') - } +// test('can stream groups', async () => { +// const [alixClient, boClient, caroClient] = await createClients(3) + +// // Start streaming groups +// const groups: Group[] = [] +// const cancelStreamGroups = await alixClient.conversations.streamGroups( +// async (group: Group) => { +// groups.push(group) +// } +// ) + +// // caro creates a group with alix, so stream callback is fired +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// const caroGroup = await caroClient.conversations.newGroup([ +// alixClient.address, +// ]) +// await delayToPropogate() +// if ((groups.length as number) !== 1) { +// throw Error('Unexpected num groups (should be 1): ' + groups.length) +// } - const canMessageV3 = await caro.canGroupMessage([ - caro.address, - alix.address, - '0x0000000000000000000000000000000000000000', - ]) +// // bo creates a group with alix so a stream callback is fired +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// const boGroup = await boClient.conversations.newGroup([alixClient.address]) +// await delayToPropogate() +// if ((groups.length as number) !== 2) { +// throw Error('Unexpected num groups (should be 2): ' + groups.length) +// } - assert( - canMessageV3['0x0000000000000000000000000000000000000000'] === false, - `should not be able to message 0x0000000000000000000000000000000000000000` - ) +// // * Note alix creating a group does not trigger alix conversations +// // group stream. Workaround is to syncGroups after you create and list manually +// // See https://github.com/xmtp/libxmtp/issues/504 - assert( - canMessageV3[caro.address.toLowerCase()] === true, - `should be able to message ${caro.address}` - ) +// // alix creates a group +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// const alixGroup = await alixClient.conversations.newGroup([ +// boClient.address, +// caroClient.address, +// ]) +// await delayToPropogate() +// if (groups.length !== 2) { +// throw Error('Expected group length 2 but it is: ' + groups.length) +// } +// // Sync groups after creation if you created a group +// const listedGroups = await alixClient.conversations.listGroups() +// await delayToPropogate() +// groups.push(listedGroups[listedGroups.length - 1]) +// if ((groups.length as number) !== 3) { +// throw Error('Expected group length 3 but it is: ' + groups.length) +// } - assert( - canMessageV3[alix.address.toLowerCase()] === true, - `should be able to message ${alix.address}` - ) +// cancelStreamGroups() +// await delayToPropogate() - return true -}) +// // Creating a group should no longer trigger stream groups +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// const caroSecond = await caroClient.conversations.newGroup([ +// alixClient.address, +// ]) +// await delayToPropogate() +// if ((groups.length as number) !== 3) { +// throw Error('Unexpected num groups (should be 3): ' + groups.length) +// } -test('can stream group messages', async () => { - // Create three MLS enabled Clients - const [alixClient, boClient, caroClient] = await createClients(3) - - // alix creates a group - const alixGroup = await alixClient.conversations.newGroup([ - boClient.address, - caroClient.address, - ]) - - // Record message stream for this group - const groupMessages: DecodedMessage[] = [] - const cancelGroupMessageStream = await alixGroup.streamGroupMessages( - async (message) => { - groupMessages.push(message) - } - ) +// return true +// }) - // bo's num groups == 1 - await boClient.conversations.syncGroups() - const boGroup = (await boClient.conversations.listGroups())[0] - - for (let i = 0; i < 5; i++) { - await boGroup.send({ text: `Message ${i}` }) - await delayToPropogate() - } - - if (groupMessages.length !== 5) { - throw Error('Unexpected convo messages count ' + groupMessages.length) - } - for (let i = 0; i < 5; i++) { - if (groupMessages[i].content() !== `Message ${i}`) { - throw Error( - 'Unexpected group message content ' + groupMessages[i].content() - ) - } - } - - cancelGroupMessageStream() - for (let i = 0; i < 5; i++) { - await boGroup.send({ text: `Message ${i}` }) - } - - if (groupMessages.length !== 5) { - throw Error('Unexpected convo messages count ' + groupMessages.length) - } +// test('can list all groups and conversations', async () => { +// const [alixClient, boClient, caroClient] = await createClients(3) + +// // Add one group and one conversation +// const boGroup = await boClient.conversations.newGroup([alixClient.address]) +// const alixConversation = await alixClient.conversations.newConversation( +// caroClient.address +// ) + +// const listedContainers = await alixClient.conversations.listAll() + +// // Verify information in listed containers is correct +// // BUG - List All returns in Chronological order on iOS +// // and reverse Chronological order on Android +// const first = isIos() ? 1 : 0 +// const second = isIos() ? 0 : 1 +// if ( +// listedContainers[first].topic !== boGroup.topic || +// listedContainers[first].version !== ConversationVersion.GROUP || +// listedContainers[second].version !== ConversationVersion.DIRECT || +// listedContainers[second].createdAt !== alixConversation.createdAt +// ) { +// throw Error('Listed containers should match streamed containers') +// } - return true -}) +// return true +// }) -test('can stream all messages', async () => { - const [alix, bo, caro] = await createClients(3) +// test('can stream all groups and conversations', async () => { +// const [alixClient, boClient, caroClient] = await createClients(3) - await delayToPropogate() +// // Start streaming groups and conversations +// const containers: ConversationContainer[] = [] +// const cancelStreamAll = await alixClient.conversations.streamAll( +// async (conversationContainer: ConversationContainer) => { +// containers.push(conversationContainer) +// } +// ) - // Record message stream across all conversations - const allMessages: DecodedMessage[] = [] - await alix.conversations.streamAllMessages(async (message) => { - allMessages.push(message) - }) +// // bo creates a group with alix, so stream callback is fired +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// const boGroup = await boClient.conversations.newGroup([alixClient.address]) +// await delayToPropogate() +// if ((containers.length as number) !== 1) { +// throw Error('Unexpected num groups (should be 1): ' + containers.length) +// } - // Start bo starts a new conversation. - const boConvo = await bo.conversations.newConversation(alix.address) - await delayToPropogate() +// // bo creates a v2 Conversation with alix so a stream callback is fired +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// const boConversation = await boClient.conversations.newConversation( +// alixClient.address +// ) +// await delayToPropogate() +// if ((containers.length as number) !== 2) { +// throw Error('Unexpected num groups (should be 2): ' + containers.length) +// } - for (let i = 0; i < 5; i++) { - await boConvo.send({ text: `Message ${i}` }) - await delayToPropogate() - } +// if ( +// containers[1].version === ConversationVersion.DIRECT && +// boConversation.conversationID !== +// (containers[1] as Conversation).conversationID +// ) { +// throw Error( +// 'Conversation from streamed all should match conversationID with created conversation' +// ) +// } - const count = allMessages.length - if (count !== 5) { - throw Error('Unexpected all messages count ' + allMessages.length) - } +// // * Note alix creating a v2 Conversation does trigger alix conversations +// // stream. - const caroConvo = await caro.conversations.newConversation(alix.address) - const caroGroup = await caro.conversations.newGroup([alix.address]) - await delayToPropogate() - for (let i = 0; i < 5; i++) { - await caroConvo.send({ text: `Message ${i}` }) - await caroGroup.send({ text: `Message ${i}` }) - await delayToPropogate() - } +// // alix creates a V2 Conversationgroup +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// const alixConversation = await alixClient.conversations.newConversation( +// caroClient.address +// ) +// await delayToPropogate() +// if (containers.length !== 3) { +// throw Error('Expected group length 3 but it is: ' + containers.length) +// } - if (allMessages.length !== 10) { - throw Error('Unexpected all messages count ' + allMessages.length) - } +// cancelStreamAll() +// await delayToPropogate() - alix.conversations.cancelStreamAllMessages() +// // Creating a group should no longer trigger stream groups +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// const caroConversation = await caroClient.conversations.newGroup([ +// alixClient.address, +// ]) +// await delayToPropogate() +// if ((containers.length as number) !== 3) { +// throw Error('Unexpected num groups (should be 3): ' + containers.length) +// } - await alix.conversations.streamAllMessages(async (message) => { - allMessages.push(message) - }, true) +// return true +// }) - for (let i = 0; i < 5; i++) { - await boConvo.send({ text: `Message ${i}` }) - await caroGroup.send({ text: `Message ${i}` }) - await delayToPropogate() - } - if (allMessages.length <= 15) { - throw Error('Unexpected all messages count ' + allMessages.length) - } +// test('canMessage', async () => { +// const [bo, alix, caro] = await createClients(3) - return true -}) +// const canMessage = await bo.canMessage(alix.address) +// if (!canMessage) { +// throw new Error('should be able to message v2 client') +// } -test('can make a group with admin permissions', async () => { - const [adminClient, anotherClient] = await createClients(2) +// const canMessageV3 = await caro.canGroupMessage([ +// caro.address, +// alix.address, +// '0x0000000000000000000000000000000000000000', +// ]) - const group = await adminClient.conversations.newGroup( - [anotherClient.address], - 'admin_only' - ) +// assert( +// canMessageV3['0x0000000000000000000000000000000000000000'] === false, +// `should not be able to message 0x0000000000000000000000000000000000000000` +// ) - if (group.permissionLevel !== 'admin_only') { - throw Error( - `Group permission level should be admin_only but was ${group.permissionLevel}` - ) - } +// assert( +// canMessageV3[caro.address.toLowerCase()] === true, +// `should be able to message ${caro.address}` +// ) - const isAdmin = await group.isAdmin(adminClient.inboxId) - if (!isAdmin) { - throw Error(`adminClient should be the admin`) - } +// assert( +// canMessageV3[alix.address.toLowerCase()] === true, +// `should be able to message ${alix.address}` +// ) - // Creator id not working, see https://github.com/xmtp/libxmtp/issues/788 - // if (group.creatorInboxId !== adminClient.inboxId) { - // throw Error( - // `adminClient should be the creator but was ${group.creatorInboxId}` - // ) - // } +// return true +// }) - return true -}) +// test('can stream group messages', async () => { +// // Create three MLS enabled Clients +// const [alixClient, boClient, caroClient] = await createClients(3) + +// // alix creates a group +// const alixGroup = await alixClient.conversations.newGroup([ +// boClient.address, +// caroClient.address, +// ]) + +// // Record message stream for this group +// const groupMessages: DecodedMessage[] = [] +// const cancelGroupMessageStream = await alixGroup.streamGroupMessages( +// async (message) => { +// groupMessages.push(message) +// } +// ) + +// // bo's num groups == 1 +// await boClient.conversations.syncGroups() +// const boGroup = (await boClient.conversations.listGroups())[0] + +// for (let i = 0; i < 5; i++) { +// await boGroup.send({ text: `Message ${i}` }) +// await delayToPropogate() +// } -test('can paginate group messages', async () => { - // Create three MLS enabled Clients - const [alixClient, boClient] = await createClients(2) +// if (groupMessages.length !== 5) { +// throw Error('Unexpected convo messages count ' + groupMessages.length) +// } +// for (let i = 0; i < 5; i++) { +// if (groupMessages[i].content() !== `Message ${i}`) { +// throw Error( +// 'Unexpected group message content ' + groupMessages[i].content() +// ) +// } +// } - // alix creates a group - const alixGroup = await alixClient.conversations.newGroup([boClient.address]) +// cancelGroupMessageStream() +// for (let i = 0; i < 5; i++) { +// await boGroup.send({ text: `Message ${i}` }) +// } - // alix can send messages - await alixGroup.send('hello, world') - await alixGroup.send('gm') +// if (groupMessages.length !== 5) { +// throw Error('Unexpected convo messages count ' + groupMessages.length) +// } - await boClient.conversations.syncGroups() - const boGroups = await boClient.conversations.listGroups() - if (boGroups.length !== 1) { - throw new Error( - 'num groups for bo should be 1, but it is' + boGroups.length - ) - } - await delayToPropogate() - // bo can read messages from alix - await boGroups[0].sync() - const boMessages: DecodedMessage[] = await boGroups[0].messages({ - limit: 1, - }) +// return true +// }) - if (boMessages.length !== 1) { - throw Error(`Should limit just 1 message but was ${boMessages.length}`) - } +// test('can stream all messages', async () => { +// const [alix, bo, caro] = await createClients(3) - return true -}) +// await delayToPropogate() -test('can stream all group messages', async () => { - const [alix, bo, caro] = await createClients(3) +// // Record message stream across all conversations +// const allMessages: DecodedMessage[] = [] +// await alix.conversations.streamAllMessages(async (message) => { +// allMessages.push(message) +// }) - await delayToPropogate() +// // Start bo starts a new conversation. +// const boConvo = await bo.conversations.newConversation(alix.address) +// await delayToPropogate() - // Start bo starts a new group. - const boGroup = await bo.conversations.newGroup([alix.address]) - await delayToPropogate() +// for (let i = 0; i < 5; i++) { +// await boConvo.send({ text: `Message ${i}` }) +// await delayToPropogate() +// } - // Starts a new conversation. - const caroGroup = await caro.conversations.newGroup([alix.address]) +// const count = allMessages.length +// if (count !== 5) { +// throw Error('Unexpected all messages count ' + allMessages.length) +// } - // Record message stream across all conversations - const allMessages: DecodedMessage[] = [] - // If we don't call syncGroups here, the streamAllGroupMessages will not - // stream the first message. Feels like a bug. - await alix.conversations.syncGroups() - await alix.conversations.streamAllGroupMessages(async (message) => { - allMessages.push(message) - }) +// const caroConvo = await caro.conversations.newConversation(alix.address) +// const caroGroup = await caro.conversations.newGroup([alix.address]) +// await delayToPropogate() +// for (let i = 0; i < 5; i++) { +// await caroConvo.send({ text: `Message ${i}` }) +// await caroGroup.send({ text: `Message ${i}` }) +// await delayToPropogate() +// } - for (let i = 0; i < 5; i++) { - await boGroup.send({ text: `Message ${i}` }) - await delayToPropogate() - } +// if (allMessages.length !== 10) { +// throw Error('Unexpected all messages count ' + allMessages.length) +// } - const count = allMessages.length - if (count !== 5) { - throw Error('Unexpected all messages count first' + allMessages.length) - } +// alix.conversations.cancelStreamAllMessages() - await delayToPropogate() - for (let i = 0; i < 5; i++) { - await caroGroup.send({ text: `Message ${i}` }) - await delayToPropogate() - } +// await alix.conversations.streamAllMessages(async (message) => { +// allMessages.push(message) +// }, true) - if (allMessages.length !== 10) { - throw Error('Unexpected all messages count second' + allMessages.length) - } +// for (let i = 0; i < 5; i++) { +// await boConvo.send({ text: `Message ${i}` }) +// await caroGroup.send({ text: `Message ${i}` }) +// await delayToPropogate() +// } +// if (allMessages.length <= 15) { +// throw Error('Unexpected all messages count ' + allMessages.length) +// } - alix.conversations.cancelStreamAllGroupMessages() - await delayToPropogate() - await alix.conversations.streamAllGroupMessages(async (message) => { - allMessages.push(message) - }) +// return true +// }) - for (let i = 0; i < 5; i++) { - await boGroup.send({ text: `Message ${i}` }) - await delayToPropogate() - } - if (allMessages.length <= 10) { - throw Error('Unexpected all messages count ' + allMessages.length) - } +// test('can make a group with admin permissions', async () => { +// const [adminClient, anotherClient] = await createClients(2) - return true -}) +// const group = await adminClient.conversations.newGroup( +// [anotherClient.address], +// 'admin_only' +// ) -test('can streamAll from multiple clients', async () => { - const [alix, bo, caro] = await createClients(3) +// if (group.permissionLevel !== 'admin_only') { +// throw Error( +// `Group permission level should be admin_only but was ${group.permissionLevel}` +// ) +// } - // Setup stream alls - const allBoConversations: any[] = [] - const allAliConversations: any[] = [] +// const isAdmin = await group.isAdmin(adminClient.inboxId) +// if (!isAdmin) { +// throw Error(`adminClient should be the admin`) +// } - await bo.conversations.streamAll(async (conversation) => { - allBoConversations.push(conversation) - }) - await alix.conversations.streamAll(async (conversation) => { - allAliConversations.push(conversation) - }) +// // Creator id not working, see https://github.com/xmtp/libxmtp/issues/788 +// // if (group.creatorInboxId !== adminClient.inboxId) { +// // throw Error( +// // `adminClient should be the creator but was ${group.creatorInboxId}` +// // ) +// // } - // Start Caro starts a new conversation. - await caro.conversations.newConversation(alix.address) - await delayToPropogate() - if (allBoConversations.length !== 0) { - throw Error( - 'Unexpected all conversations count for Bo ' + - allBoConversations.length + - ' and Alix had ' + - allAliConversations.length - ) - } - if (allAliConversations.length !== 1) { - throw Error( - 'Unexpected all conversations count ' + allAliConversations.length - ) - } - return true -}) +// return true +// }) -test('can streamAll from multiple clients - swapped orderring', async () => { - const [alix, bo, caro] = await createClients(3) +// test('can paginate group messages', async () => { +// // Create three MLS enabled Clients +// const [alixClient, boClient] = await createClients(2) - // Setup stream alls - const allBoConversations: any[] = [] - const allAliConversations: any[] = [] +// // alix creates a group +// const alixGroup = await alixClient.conversations.newGroup([boClient.address]) - await alix.conversations.streamAll(async (conversation) => { - allAliConversations.push(conversation) - }) +// // alix can send messages +// await alixGroup.send('hello, world') +// await alixGroup.send('gm') - await bo.conversations.streamAll(async (conversation) => { - allBoConversations.push(conversation) - }) +// await boClient.conversations.syncGroups() +// const boGroups = await boClient.conversations.listGroups() +// if (boGroups.length !== 1) { +// throw new Error( +// 'num groups for bo should be 1, but it is' + boGroups.length +// ) +// } +// await delayToPropogate() +// // bo can read messages from alix +// await boGroups[0].sync() +// const boMessages: DecodedMessage[] = await boGroups[0].messages({ +// limit: 1, +// }) + +// if (boMessages.length !== 1) { +// throw Error(`Should limit just 1 message but was ${boMessages.length}`) +// } - // Start Caro starts a new conversation. - await caro.conversations.newConversation(alix.address) - await delayToPropogate() - if (allBoConversations.length !== 0) { - throw Error( - 'Unexpected all conversations count for Bo ' + - allBoConversations.length + - ' and Alix had ' + - allAliConversations.length - ) - } - if (allAliConversations.length !== 1) { - throw Error( - 'Unexpected all conversations count ' + allAliConversations.length - ) - } - return true -}) +// return true +// }) -test('can streamAllMessages from multiple clients', async () => { - const [alix, bo, caro] = await createClients(3) +// test('can stream all group messages', async () => { +// const [alix, bo, caro] = await createClients(3) - // Setup stream - const allBoMessages: any[] = [] - const allAliMessages: any[] = [] +// await delayToPropogate() - await bo.conversations.streamAllMessages(async (conversation) => { - allBoMessages.push(conversation) - }, true) - await alix.conversations.streamAllMessages(async (conversation) => { - allAliMessages.push(conversation) - }, true) +// // Start bo starts a new group. +// const boGroup = await bo.conversations.newGroup([alix.address]) +// await delayToPropogate() - // Start Caro starts a new conversation. - const caroConversation = await caro.conversations.newConversation( - alix.address - ) - await caroConversation.send({ text: `Message` }) - await delayToPropogate() - if (allBoMessages.length !== 0) { - throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) - } +// // Starts a new conversation. +// const caroGroup = await caro.conversations.newGroup([alix.address]) + +// // Record message stream across all conversations +// const allMessages: DecodedMessage[] = [] +// // If we don't call syncGroups here, the streamAllGroupMessages will not +// // stream the first message. Feels like a bug. +// await alix.conversations.syncGroups() +// await alix.conversations.streamAllGroupMessages(async (message) => { +// allMessages.push(message) +// }) + +// for (let i = 0; i < 5; i++) { +// await boGroup.send({ text: `Message ${i}` }) +// await delayToPropogate() +// } - if (allAliMessages.length !== 1) { - throw Error( - 'Unexpected all conversations count for Ali ' + allAliMessages.length - ) - } +// const count = allMessages.length +// if (count !== 5) { +// throw Error('Unexpected all messages count first' + allMessages.length) +// } - return true -}) +// await delayToPropogate() +// for (let i = 0; i < 5; i++) { +// await caroGroup.send({ text: `Message ${i}` }) +// await delayToPropogate() +// } -test('can streamAllMessages from multiple clients - swapped', async () => { - const [alix, bo, caro] = await createClients(3) +// if (allMessages.length !== 10) { +// throw Error('Unexpected all messages count second' + allMessages.length) +// } - // Setup stream - const allBoMessages: any[] = [] - const allAliMessages: any[] = [] - const caroGroup = await caro.conversations.newGroup([alix.address]) +// alix.conversations.cancelStreamAllGroupMessages() +// await delayToPropogate() +// await alix.conversations.streamAllGroupMessages(async (message) => { +// allMessages.push(message) +// }) - await alix.conversations.streamAllMessages(async (conversation) => { - allAliMessages.push(conversation) - }, true) - await bo.conversations.streamAllMessages(async (conversation) => { - allBoMessages.push(conversation) - }, true) +// for (let i = 0; i < 5; i++) { +// await boGroup.send({ text: `Message ${i}` }) +// await delayToPropogate() +// } +// if (allMessages.length <= 10) { +// throw Error('Unexpected all messages count ' + allMessages.length) +// } - // Start Caro starts a new conversation. - const caroConvo = await caro.conversations.newConversation(alix.address) - await delayToPropogate() - await caroConvo.send({ text: `Message` }) - await caroGroup.send({ text: `Message` }) - await delayToPropogate() - if (allBoMessages.length !== 0) { - throw Error( - 'Unexpected all conversations count for Bo ' + allBoMessages.length - ) - } - - if (allAliMessages.length !== 2) { - throw Error( - 'Unexpected all conversations count for Ali ' + allAliMessages.length - ) - } +// return true +// }) - return true -}) +// test('can streamAll from multiple clients', async () => { +// const [alix, bo, caro] = await createClients(3) -test('can stream all group Messages from multiple clients', async () => { - const [alix, bo, caro] = await createClients(3) +// // Setup stream alls +// const allBoConversations: any[] = [] +// const allAliConversations: any[] = [] - // Setup stream - const allAlixMessages: DecodedMessage[] = [] - const allBoMessages: DecodedMessage[] = [] - const alixGroup = await caro.conversations.newGroup([alix.address]) - const boGroup = await caro.conversations.newGroup([bo.address]) +// await bo.conversations.streamAll(async (conversation) => { +// allBoConversations.push(conversation) +// }) +// await alix.conversations.streamAll(async (conversation) => { +// allAliConversations.push(conversation) +// }) - await alixGroup.streamGroupMessages(async (message) => { - allAlixMessages.push(message) - }) - await boGroup.streamGroupMessages(async (message) => { - allBoMessages.push(message) - }) +// // Start Caro starts a new conversation. +// await caro.conversations.newConversation(alix.address) +// await delayToPropogate() +// if (allBoConversations.length !== 0) { +// throw Error( +// 'Unexpected all conversations count for Bo ' + +// allBoConversations.length + +// ' and Alix had ' + +// allAliConversations.length +// ) +// } +// if (allAliConversations.length !== 1) { +// throw Error( +// 'Unexpected all conversations count ' + allAliConversations.length +// ) +// } +// return true +// }) - // Start Caro starts a new conversation. - await delayToPropogate() - await alixGroup.send({ text: `Message` }) - await delayToPropogate() - if (allBoMessages.length !== 0) { - throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) - } - - if (allAlixMessages.length !== 1) { - throw Error( - 'Unexpected all messages count for Ali ' + allAlixMessages.length - ) - } - - await alix.conversations.syncGroups() - const alixConv = (await alix.conversations.listGroups())[0] - await alixConv.send({ text: `Message` }) - await delayToPropogate() - if (allBoMessages.length !== 0) { - throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) - } - // @ts-ignore-next-line - if (allAlixMessages.length !== 2) { - throw Error( - 'Unexpected all messages count for Ali ' + allAlixMessages.length - ) - } +// test('can streamAll from multiple clients - swapped orderring', async () => { +// const [alix, bo, caro] = await createClients(3) - return true -}) +// // Setup stream alls +// const allBoConversations: any[] = [] +// const allAliConversations: any[] = [] -test('can stream all group Messages from multiple clients - swapped', async () => { - const [alix, bo, caro] = await createClients(3) +// await alix.conversations.streamAll(async (conversation) => { +// allAliConversations.push(conversation) +// }) - // Setup stream - const allAlixMessages: DecodedMessage[] = [] - const allBoMessages: DecodedMessage[] = [] - const alixGroup = await caro.conversations.newGroup([alix.address]) - const boGroup = await caro.conversations.newGroup([bo.address]) +// await bo.conversations.streamAll(async (conversation) => { +// allBoConversations.push(conversation) +// }) - await boGroup.streamGroupMessages(async (message) => { - allBoMessages.push(message) - }) - await alixGroup.streamGroupMessages(async (message) => { - allAlixMessages.push(message) - }) +// // Start Caro starts a new conversation. +// await caro.conversations.newConversation(alix.address) +// await delayToPropogate() +// if (allBoConversations.length !== 0) { +// throw Error( +// 'Unexpected all conversations count for Bo ' + +// allBoConversations.length + +// ' and Alix had ' + +// allAliConversations.length +// ) +// } +// if (allAliConversations.length !== 1) { +// throw Error( +// 'Unexpected all conversations count ' + allAliConversations.length +// ) +// } +// return true +// }) - // Start Caro starts a new conversation. - await delayToPropogate() - await alixGroup.send({ text: `Message` }) - await delayToPropogate() - if (allBoMessages.length !== 0) { - throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) - } - - if (allAlixMessages.length !== 1) { - throw Error( - 'Unexpected all messages count for Ali ' + allAlixMessages.length - ) - } - - await alix.conversations.syncGroups() - const alixConv = (await alix.conversations.listGroups())[0] - await alixConv.send({ text: `Message` }) - await delayToPropogate() - if (allBoMessages.length !== 0) { - throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) - } - // @ts-ignore-next-line - if (allAlixMessages.length !== 2) { - throw Error( - 'Unexpected all messages count for Ali ' + allAlixMessages.length - ) - } +// test('can streamAllMessages from multiple clients', async () => { +// const [alix, bo, caro] = await createClients(3) - return true -}) +// // Setup stream +// const allBoMessages: any[] = [] +// const allAliMessages: any[] = [] -test('creating a group should allow group', async () => { - const [alix, bo] = await createClients(2) +// await bo.conversations.streamAllMessages(async (conversation) => { +// allBoMessages.push(conversation) +// }, true) +// await alix.conversations.streamAllMessages(async (conversation) => { +// allAliMessages.push(conversation) +// }, true) - const group = await alix.conversations.newGroup([bo.address]) - const consent = await alix.contacts.isGroupAllowed(group.id) - const groupConsent = await group.isAllowed() +// // Start Caro starts a new conversation. +// const caroConversation = await caro.conversations.newConversation( +// alix.address +// ) +// await caroConversation.send({ text: `Message` }) +// await delayToPropogate() +// if (allBoMessages.length !== 0) { +// throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) +// } - if (!consent || !groupConsent) { - throw Error('Group should be allowed') - } +// if (allAliMessages.length !== 1) { +// throw Error( +// 'Unexpected all conversations count for Ali ' + allAliMessages.length +// ) +// } - const state = await group.consentState() - assert( - state === 'allowed', - `the message should have a consent state of allowed but was ${state}` - ) +// return true +// }) - const consentList = await alix.contacts.consentList() - assert( - consentList[0].permissionType === 'allowed', - `the message should have a consent state of allowed but was ${consentList[0].permissionType}` - ) +// test('can streamAllMessages from multiple clients - swapped', async () => { +// const [alix, bo, caro] = await createClients(3) - return true -}) +// // Setup stream +// const allBoMessages: any[] = [] +// const allAliMessages: any[] = [] +// const caroGroup = await caro.conversations.newGroup([alix.address]) -test('can allow a group', async () => { - const [alix, bo] = await createClients(2) - const alixGroup = await alix.conversations.newGroup([bo.address]) - const startConsent = await bo.contacts.isGroupAllowed(alixGroup.id) - if (startConsent) { - throw Error('Group should not be allowed') - } - await bo.contacts.allowGroups([alixGroup.id]) - const isAllowed = await bo.contacts.isGroupAllowed(alixGroup.id) - if (!isAllowed) { - throw Error('Group should be allowed') - } +// await alix.conversations.streamAllMessages(async (conversation) => { +// allAliMessages.push(conversation) +// }, true) +// await bo.conversations.streamAllMessages(async (conversation) => { +// allBoMessages.push(conversation) +// }, true) - return true -}) +// // Start Caro starts a new conversation. +// const caroConvo = await caro.conversations.newConversation(alix.address) +// await delayToPropogate() +// await caroConvo.send({ text: `Message` }) +// await caroGroup.send({ text: `Message` }) +// await delayToPropogate() +// if (allBoMessages.length !== 0) { +// throw Error( +// 'Unexpected all conversations count for Bo ' + allBoMessages.length +// ) +// } -test('can deny a group', async () => { - const [alix, bo] = await createClients(2) - const alixGroup = await alix.conversations.newGroup([bo.address]) - const startConsent = await bo.contacts.isGroupDenied(alixGroup.id) - if (startConsent) { - throw Error('Group should be unknown') - } - await bo.contacts.denyGroups([alixGroup.id]) - await bo.conversations.syncGroups() - const boGroups = await bo.conversations.listGroups() - const isDenied = await bo.contacts.isGroupDenied(alixGroup.id) - const isGroupDenied = await boGroups[0].isDenied() - if (!isDenied || !isGroupDenied) { - throw Error('Group should be denied') - } - await bo.contacts.allowGroups([alixGroup.id]) - const isAllowed = await bo.contacts.isGroupAllowed(alixGroup.id) - if (!isAllowed) { - throw Error('Group should be allowed') - } +// if (allAliMessages.length !== 2) { +// throw Error( +// 'Unexpected all conversations count for Ali ' + allAliMessages.length +// ) +// } - return true -}) +// return true +// }) -test('can allow and deny a inbox id', async () => { - const [alix, bo] = await createClients(2) - const startConsent = await bo.contacts.isInboxAllowed(alix.inboxId) - if (startConsent) { - throw Error('inbox id should be unknown') - } - await bo.contacts.denyInboxes([alix.inboxId]) - const isDenied = await bo.contacts.isInboxDenied(alix.inboxId) - if (!isDenied) { - throw Error('inbox id should be denied') - } - await bo.contacts.allowInboxes([alix.inboxId]) - const isAllowed = await bo.contacts.isInboxAllowed(alix.inboxId) - if (!isAllowed) { - throw Error('inbox id should be allowed') - } - - const consentList = await bo.contacts.consentList() - assert( - consentList[0].entryType === 'inbox_id', - `the message should have a type of inbox_id but was ${consentList[0].entryType}` - ) +// test('can stream all group Messages from multiple clients', async () => { +// const [alix, bo, caro] = await createClients(3) - return true -}) +// // Setup stream +// const allAlixMessages: DecodedMessage[] = [] +// const allBoMessages: DecodedMessage[] = [] +// const alixGroup = await caro.conversations.newGroup([alix.address]) +// const boGroup = await caro.conversations.newGroup([bo.address]) -test('can check if group is allowed', async () => { - const [alix, bo] = await createClients(2) - const alixGroup = await alix.conversations.newGroup([bo.address]) - const startConsent = await bo.contacts.isGroupAllowed(alixGroup.id) - if (startConsent) { - throw Error('Group should not be allowed by default') - } - await bo.contacts.allowGroups([alixGroup.id]) - const consent = await bo.contacts.isGroupAllowed(alixGroup.id) - if (!consent) { - throw Error('Group should be allowed') - } +// await alixGroup.streamGroupMessages(async (message) => { +// allAlixMessages.push(message) +// }) +// await boGroup.streamGroupMessages(async (message) => { +// allBoMessages.push(message) +// }) - return true -}) +// // Start Caro starts a new conversation. +// await delayToPropogate() +// await alixGroup.send({ text: `Message` }) +// await delayToPropogate() +// if (allBoMessages.length !== 0) { +// throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) +// } -test('can check if group is denied', async () => { - const [alix, bo] = await createClients(2) - const alixGroup = await alix.conversations.newGroup([bo.address]) - const startConsent = await bo.contacts.isGroupDenied(alixGroup.id) - if (startConsent) { - throw Error('Group should not be denied by default') - } - await bo.contacts.denyGroups([alixGroup.id]) - const consent = await bo.contacts.isGroupDenied(alixGroup.id) - if (!consent) { - throw Error('Group should be denied') - } - return true -}) +// if (allAlixMessages.length !== 1) { +// throw Error( +// 'Unexpected all messages count for Ali ' + allAlixMessages.length +// ) +// } -test('sync function behaves as expected', async () => { - const [alix, bo, caro] = await createClients(3) - const alixGroup = await alix.conversations.newGroup([bo.address]) +// await alix.conversations.syncGroups() +// const alixConv = (await alix.conversations.listGroups())[0] +// await alixConv.send({ text: `Message` }) +// await delayToPropogate() +// if (allBoMessages.length !== 0) { +// throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) +// } +// // @ts-ignore-next-line +// if (allAlixMessages.length !== 2) { +// throw Error( +// 'Unexpected all messages count for Ali ' + allAlixMessages.length +// ) +// } - await alixGroup.send({ text: 'hello' }) +// return true +// }) - // List groups will return empty until the first sync - let boGroups = await bo.conversations.listGroups() - assert(boGroups.length === 0, 'num groups for bo is 0 until we sync') +// test('can stream all group Messages from multiple clients - swapped', async () => { +// const [alix, bo, caro] = await createClients(3) - await bo.conversations.syncGroups() +// // Setup stream +// const allAlixMessages: DecodedMessage[] = [] +// const allBoMessages: DecodedMessage[] = [] +// const alixGroup = await caro.conversations.newGroup([alix.address]) +// const boGroup = await caro.conversations.newGroup([bo.address]) - boGroups = await bo.conversations.listGroups() - assert(boGroups.length === 1, 'num groups for bo is 1') +// await boGroup.streamGroupMessages(async (message) => { +// allBoMessages.push(message) +// }) +// await alixGroup.streamGroupMessages(async (message) => { +// allAlixMessages.push(message) +// }) - // Num members will include the initial num of members even before sync - let numMembers = (await boGroups[0].memberInboxIds()).length - assert(numMembers === 2, 'num members should be 2') +// // Start Caro starts a new conversation. +// await delayToPropogate() +// await alixGroup.send({ text: `Message` }) +// await delayToPropogate() +// if (allBoMessages.length !== 0) { +// throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) +// } - // Num messages for a group will be 0 until we sync the group - let numMessages = (await boGroups[0].messages()).length - assert(numMessages === 0, 'num members should be 1') +// if (allAlixMessages.length !== 1) { +// throw Error( +// 'Unexpected all messages count for Ali ' + allAlixMessages.length +// ) +// } - await bo.conversations.syncGroups() +// await alix.conversations.syncGroups() +// const alixConv = (await alix.conversations.listGroups())[0] +// await alixConv.send({ text: `Message` }) +// await delayToPropogate() +// if (allBoMessages.length !== 0) { +// throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) +// } +// // @ts-ignore-next-line +// if (allAlixMessages.length !== 2) { +// throw Error( +// 'Unexpected all messages count for Ali ' + allAlixMessages.length +// ) +// } - // Num messages is still 0 because we didnt sync the group itself - numMessages = (await boGroups[0].messages()).length - assert(numMessages === 0, 'num messages should be 0') +// return true +// }) - await boGroups[0].sync() +// test('creating a group should allow group', async () => { +// const [alix, bo] = await createClients(2) - // after syncing the group we now see the correct number of messages - numMessages = (await boGroups[0].messages()).length - assert(numMessages === 1, 'num members should be 1') +// const group = await alix.conversations.newGroup([bo.address]) +// const consent = await alix.contacts.isGroupAllowed(group.id) +// const groupConsent = await group.isAllowed() - await alixGroup.addMembers([caro.address]) +// if (!consent || !groupConsent) { +// throw Error('Group should be allowed') +// } - numMembers = (await boGroups[0].memberInboxIds()).length - assert(numMembers === 2, 'num members should be 2') +// const state = await group.consentState() +// assert( +// state === 'allowed', +// `the message should have a consent state of allowed but was ${state}` +// ) - await bo.conversations.syncGroups() +// const consentList = await alix.contacts.consentList() +// assert( +// consentList[0].permissionType === 'allowed', +// `the message should have a consent state of allowed but was ${consentList[0].permissionType}` +// ) - // Even though we synced the groups, we need to sync the group itself to see the new member - numMembers = (await boGroups[0].memberInboxIds()).length - assert(numMembers === 2, 'num members should be 2') +// return true +// }) - await boGroups[0].sync() +// test('can allow a group', async () => { +// const [alix, bo] = await createClients(2) +// const alixGroup = await alix.conversations.newGroup([bo.address]) +// const startConsent = await bo.contacts.isGroupAllowed(alixGroup.id) +// if (startConsent) { +// throw Error('Group should not be allowed') +// } +// await bo.contacts.allowGroups([alixGroup.id]) +// const isAllowed = await bo.contacts.isGroupAllowed(alixGroup.id) +// if (!isAllowed) { +// throw Error('Group should be allowed') +// } - numMembers = (await boGroups[0].memberInboxIds()).length - assert(numMembers === 3, 'num members should be 3') +// return true +// }) - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const _alixGroup2 = await alix.conversations.newGroup([ - bo.address, - caro.address, - ]) - await bo.conversations.syncGroups() - boGroups = await bo.conversations.listGroups() - assert(boGroups.length === 2, 'num groups for bo is 2') +// test('can deny a group', async () => { +// const [alix, bo] = await createClients(2) +// const alixGroup = await alix.conversations.newGroup([bo.address]) +// const startConsent = await bo.contacts.isGroupDenied(alixGroup.id) +// if (startConsent) { +// throw Error('Group should be unknown') +// } +// await bo.contacts.denyGroups([alixGroup.id]) +// await bo.conversations.syncGroups() +// const boGroups = await bo.conversations.listGroups() +// const isDenied = await bo.contacts.isGroupDenied(alixGroup.id) +// const isGroupDenied = await boGroups[0].isDenied() +// if (!isDenied || !isGroupDenied) { +// throw Error('Group should be denied') +// } +// await bo.contacts.allowGroups([alixGroup.id]) +// const isAllowed = await bo.contacts.isGroupAllowed(alixGroup.id) +// if (!isAllowed) { +// throw Error('Group should be allowed') +// } - // Even before syncing the group, syncGroups will return the initial number of members - numMembers = (await boGroups[1].memberInboxIds()).length - assert(numMembers === 3, 'num members should be 3') +// return true +// }) - return true -}) +// test('can allow and deny a inbox id', async () => { +// const [alix, bo] = await createClients(2) +// const startConsent = await bo.contacts.isInboxAllowed(alix.inboxId) +// if (startConsent) { +// throw Error('inbox id should be unknown') +// } +// await bo.contacts.denyInboxes([alix.inboxId]) +// const isDenied = await bo.contacts.isInboxDenied(alix.inboxId) +// if (!isDenied) { +// throw Error('inbox id should be denied') +// } +// await bo.contacts.allowInboxes([alix.inboxId]) +// const isAllowed = await bo.contacts.isInboxAllowed(alix.inboxId) +// if (!isAllowed) { +// throw Error('inbox id should be allowed') +// } -test('can read and update group name', async () => { - const [alix, bo, caro] = await createClients(3) - const alixGroup = await alix.conversations.newGroup([bo.address]) +// const consentList = await bo.contacts.consentList() +// assert( +// consentList[0].entryType === 'inbox_id', +// `the message should have a type of inbox_id but was ${consentList[0].entryType}` +// ) - await alixGroup.sync() - let groupName = await alixGroup.groupName() +// return true +// }) - assert(groupName === '', 'group name should be empty string') +// test('can check if group is allowed', async () => { +// const [alix, bo] = await createClients(2) +// const alixGroup = await alix.conversations.newGroup([bo.address]) +// const startConsent = await bo.contacts.isGroupAllowed(alixGroup.id) +// if (startConsent) { +// throw Error('Group should not be allowed by default') +// } +// await bo.contacts.allowGroups([alixGroup.id]) +// const consent = await bo.contacts.isGroupAllowed(alixGroup.id) +// if (!consent) { +// throw Error('Group should be allowed') +// } - await alixGroup.updateGroupName('Test name update 1') +// return true +// }) - await alixGroup.sync() - groupName = await alixGroup.groupName() +// test('can check if group is denied', async () => { +// const [alix, bo] = await createClients(2) +// const alixGroup = await alix.conversations.newGroup([bo.address]) +// const startConsent = await bo.contacts.isGroupDenied(alixGroup.id) +// if (startConsent) { +// throw Error('Group should not be denied by default') +// } +// await bo.contacts.denyGroups([alixGroup.id]) +// const consent = await bo.contacts.isGroupDenied(alixGroup.id) +// if (!consent) { +// throw Error('Group should be denied') +// } +// return true +// }) - assert( - groupName === 'Test name update 1', - 'group name should be "Test name update 1"' - ) +// test('sync function behaves as expected', async () => { +// const [alix, bo, caro] = await createClients(3) +// const alixGroup = await alix.conversations.newGroup([bo.address]) - await bo.conversations.syncGroups() - const boGroup = (await bo.conversations.listGroups())[0] - groupName = await boGroup.groupName() +// await alixGroup.send({ text: 'hello' }) - assert(groupName === '', 'group name should be empty string') +// // List groups will return empty until the first sync +// let boGroups = await bo.conversations.listGroups() +// assert(boGroups.length === 0, 'num groups for bo is 0 until we sync') - await boGroup.sync() +// await bo.conversations.syncGroups() - groupName = await boGroup.groupName() +// boGroups = await bo.conversations.listGroups() +// assert(boGroups.length === 1, 'num groups for bo is 1') - assert( - groupName === 'Test name update 1', - 'group name should be "Test name update 1"' - ) +// // Num members will include the initial num of members even before sync +// let numMembers = (await boGroups[0].memberInboxIds()).length +// assert(numMembers === 2, 'num members should be 2') - await alixGroup.addMembers([caro.address]) - await caro.conversations.syncGroups() - const caroGroup = (await caro.conversations.listGroups())[0] +// // Num messages for a group will be 0 until we sync the group +// let numMessages = (await boGroups[0].messages()).length +// assert(numMessages === 0, 'num members should be 1') - await caroGroup.sync() - groupName = await caroGroup.groupName() - assert( - groupName === 'Test name update 1', - 'group name should be "Test name update 1"' - ) - return true -}) +// await bo.conversations.syncGroups() -// 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', enableAlphaMls: true }) -// await delayToPropogate() -// const alix = await Client.createRandom({ env: 'local', enableAlphaMls: true }) -// await delayToPropogate() -// const caro = await Client.createRandom({ env: 'local', enableAlphaMls: true }) -// await delayToPropogate() +// // Num messages is still 0 because we didnt sync the group itself +// numMessages = (await boGroups[0].messages()).length +// assert(numMessages === 0, 'num messages should be 0') -// // Setup stream alls -// const allBoMessages: any[] = [] -// const allAliMessages: any[] = [] +// await boGroups[0].sync() -// const group = await caro.conversations.newGroup([alix.address]) -// await bo.conversations.streamAllMessages(async (conversation) => { -// allBoMessages.push(conversation) -// }, true) -// await alix.conversations.streamAllMessages(async (conversation) => { -// allAliMessages.push(conversation) -// }, true) +// // after syncing the group we now see the correct number of messages +// numMessages = (await boGroups[0].messages()).length +// assert(numMessages === 1, 'num members should be 1') -// // Wait for 15 minutes -// await delayToPropogate(15 * 1000 * 60) +// await alixGroup.addMembers([caro.address]) -// // Start Caro starts a new conversation. -// const convo = await caro.conversations.newConversation(alix.address) -// await group.send({ text: 'hello' }) -// await convo.send({ text: 'hello' }) -// await delayToPropogate() -// if (allBoMessages.length !== 0) { -// throw Error('Unexpected all conversations count ' + allBoMessages.length) -// } -// if (allAliMessages.length !== 2) { -// throw Error('Unexpected all conversations count ' + allAliMessages.length) -// } +// numMembers = (await boGroups[0].memberInboxIds()).length +// assert(numMembers === 2, 'num members should be 2') + +// await bo.conversations.syncGroups() + +// // Even though we synced the groups, we need to sync the group itself to see the new member +// numMembers = (await boGroups[0].memberInboxIds()).length +// assert(numMembers === 2, 'num members should be 2') + +// await boGroups[0].sync() + +// numMembers = (await boGroups[0].memberInboxIds()).length +// assert(numMembers === 3, 'num members should be 3') + +// // eslint-disable-next-line @typescript-eslint/no-unused-vars +// const _alixGroup2 = await alix.conversations.newGroup([ +// bo.address, +// caro.address, +// ]) +// await bo.conversations.syncGroups() +// boGroups = await bo.conversations.listGroups() +// assert(boGroups.length === 2, 'num groups for bo is 2') + +// // Even before syncing the group, syncGroups will return the initial number of members +// numMembers = (await boGroups[1].memberInboxIds()).length +// assert(numMembers === 3, 'num members should be 3') // return true // }) + +// test('can read and update group name', async () => { +// const [alix, bo, caro] = await createClients(3) +// const alixGroup = await alix.conversations.newGroup([bo.address]) + +// await alixGroup.sync() +// let groupName = await alixGroup.groupName() + +// assert(groupName === '', 'group name should be empty string') + +// await alixGroup.updateGroupName('Test name update 1') + +// await alixGroup.sync() +// groupName = await alixGroup.groupName() + +// assert( +// groupName === 'Test name update 1', +// 'group name should be "Test name update 1"' +// ) + +// await bo.conversations.syncGroups() +// const boGroup = (await bo.conversations.listGroups())[0] +// groupName = await boGroup.groupName() + +// assert(groupName === '', 'group name should be empty string') + +// await boGroup.sync() + +// groupName = await boGroup.groupName() + +// assert( +// groupName === 'Test name update 1', +// 'group name should be "Test name update 1"' +// ) + +// await alixGroup.addMembers([caro.address]) +// await caro.conversations.syncGroups() +// const caroGroup = (await caro.conversations.listGroups())[0] + +// await caroGroup.sync() +// groupName = await caroGroup.groupName() +// assert( +// groupName === 'Test name update 1', +// 'group name should be "Test name update 1"' +// ) +// 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', enableAlphaMls: true }) +// // await delayToPropogate() +// // const alix = await Client.createRandom({ env: 'local', enableAlphaMls: true }) +// // await delayToPropogate() +// // const caro = await Client.createRandom({ env: 'local', enableAlphaMls: true }) +// // await delayToPropogate() + +// // // Setup stream alls +// // const allBoMessages: any[] = [] +// // const allAliMessages: any[] = [] + +// // const group = await caro.conversations.newGroup([alix.address]) +// // await bo.conversations.streamAllMessages(async (conversation) => { +// // allBoMessages.push(conversation) +// // }, true) +// // await alix.conversations.streamAllMessages(async (conversation) => { +// // allAliMessages.push(conversation) +// // }, true) + +// // // Wait for 15 minutes +// // await delayToPropogate(15 * 1000 * 60) + +// // // Start Caro starts a new conversation. +// // const convo = await caro.conversations.newConversation(alix.address) +// // await group.send({ text: 'hello' }) +// // await convo.send({ text: 'hello' }) +// // await delayToPropogate() +// // if (allBoMessages.length !== 0) { +// // throw Error('Unexpected all conversations count ' + allBoMessages.length) +// // } +// // if (allAliMessages.length !== 2) { +// // throw Error('Unexpected all conversations count ' + allAliMessages.length) +// // } + +// // return true +// // }) diff --git a/example/src/tests/test-utils.ts b/example/src/tests/test-utils.ts index 417988969..eb09f263d 100644 --- a/example/src/tests/test-utils.ts +++ b/example/src/tests/test-utils.ts @@ -10,7 +10,7 @@ export function isIos() { return Platform.OS === 'ios' } -export async function delayToPropogate(milliseconds = 100): Promise { +export async function delayToPropogate(milliseconds = 1000): Promise { // delay avoid clobbering return new Promise((r) => setTimeout(r, milliseconds)) } From 5b234dd9c5bcae9cc3085e4a2a96a4030240e418 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 12 Jun 2024 23:39:46 -0700 Subject: [PATCH 2/3] get all the tests passing --- example/ios/Podfile.lock | 8 +- example/src/tests/groupTests.ts | 2795 +++++++++++++++---------------- ios/XMTPReactNative.podspec | 2 +- 3 files changed, 1401 insertions(+), 1404 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 0f23166df..a2f8a1719 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.11.5): + - XMTP (0.11.6): - Connect-Swift (= 0.12.0) - GzipSwift - LibXMTP (= 0.5.1-beta1) @@ -458,7 +458,7 @@ PODS: - ExpoModulesCore - MessagePacker - secp256k1.swift - - XMTP (= 0.11.5) + - XMTP (= 0.11.6) - Yoga (1.14.0) DEPENDENCIES: @@ -763,8 +763,8 @@ SPEC CHECKSUMS: secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1 web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959 - XMTP: 3947ed08f7b1c50878b145e4990e604abf741ba9 - XMTPReactNative: 08e92e5c83de18c18af7e9251f348495a3f41e15 + XMTP: 5986c7bc1400b8b054569d4c7c6d2f673d992be1 + XMTPReactNative: ed4824399c26767008b8266992085461f0cece98 Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9 PODFILE CHECKSUM: 95d6ace79946933ecf80684613842ee553dd76a2 diff --git a/example/src/tests/groupTests.ts b/example/src/tests/groupTests.ts index 620f19c66..b351309bb 100644 --- a/example/src/tests/groupTests.ts +++ b/example/src/tests/groupTests.ts @@ -23,1611 +23,1608 @@ function test(name: string, perform: () => Promise) { groupTests.push({ name: String(counter++) + '. ' + name, run: perform }) } -test('reproduce streaming error', async () => { - const [alix, bo] = await createClients(2) - console.log('created clients') - - let groupCallbacks = 0 - let messageCallbacks = 0 - await bo.conversations.streamGroups(async () => { - console.log('message received') - groupCallbacks++ +test('can make a MLS V3 client', async () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const client = await Client.createRandom({ + env: 'local', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, }) - await bo.conversations.streamAllMessages(async () => { - console.log('message received') - messageCallbacks++ - }, true) - - const group = await alix.conversations.newGroup([bo.address]) - await group.send('hello') - - await delayToPropogate() - await new Promise((resolve) => setTimeout(resolve, 10000)) - assert(groupCallbacks === 1, 'group stream should have received 1 group') // <--- Fails here - assert( - messageCallbacks === 1, - 'message stream should have received 1 message' - ) return true }) -// test('can make a MLS V3 client', async () => { -// // eslint-disable-next-line @typescript-eslint/no-unused-vars -// const client = await Client.createRandom({ -// env: 'local', -// appVersion: 'Testing/0.0.0', -// enableAlphaMls: true, -// }) - -// return true -// }) - -// test('can delete a local database', async () => { -// let [client, anotherClient] = await createClients(2) - -// await client.conversations.newGroup([anotherClient.address]) -// await client.conversations.syncGroups() -// assert( -// (await client.conversations.listGroups()).length === 1, -// `should have a group size of 1 but was ${ -// (await client.conversations.listGroups()).length -// }` -// ) - -// await client.deleteLocalDatabase() -// client = await Client.createRandom({ -// env: 'local', -// appVersion: 'Testing/0.0.0', -// enableAlphaMls: true, -// dbEncryptionKey: new Uint8Array([ -// 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, -// 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, -// 145, -// ]), -// }) -// await client.conversations.syncGroups() -// assert( -// (await client.conversations.listGroups()).length === 0, -// `should have a group size of 0 but was ${ -// (await client.conversations.listGroups()).length -// }` -// ) - -// return true -// }) - -// test('can make a MLS V3 client with encryption key and database directory', async () => { -// // eslint-disable-next-line @typescript-eslint/no-unused-vars -// const dbDirPath = `${RNFS.DocumentDirectoryPath}/xmtp_db` -// const directoryExists = await RNFS.exists(dbDirPath) -// if (!directoryExists) { -// await RNFS.mkdir(dbDirPath) -// } -// const key = new Uint8Array([ -// 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, -// 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, -// ]) - -// const client = await Client.createRandom({ -// env: 'local', -// appVersion: 'Testing/0.0.0', -// enableAlphaMls: true, -// dbEncryptionKey: key, -// dbDirectory: dbDirPath, -// }) - -// const anotherClient = await Client.createRandom({ -// env: 'local', -// appVersion: 'Testing/0.0.0', -// enableAlphaMls: true, -// dbEncryptionKey: key, -// }) - -// await client.conversations.newGroup([anotherClient.address]) -// assert( -// (await client.conversations.listGroups()).length === 1, -// `should have a group size of 1 but was ${ -// (await client.conversations.listGroups()).length -// }` -// ) - -// const bundle = await client.exportKeyBundle() -// const clientFromBundle = await Client.createFromKeyBundle(bundle, { -// env: 'local', -// appVersion: 'Testing/0.0.0', -// enableAlphaMls: true, -// dbEncryptionKey: key, -// dbDirectory: dbDirPath, -// }) - -// assert( -// clientFromBundle.address === client.address, -// `clients dont match ${client.address} and ${clientFromBundle.address}` -// ) - -// assert( -// (await clientFromBundle.conversations.listGroups()).length === 1, -// `should have a group size of 1 but was ${ -// (await clientFromBundle.conversations.listGroups()).length -// }` -// ) -// return true -// }) - -// test('can drop a local database', async () => { -// const [client, anotherClient] = await createClients(2) - -// const group = await client.conversations.newGroup([anotherClient.address]) -// await client.conversations.syncGroups() -// assert( -// (await client.conversations.listGroups()).length === 1, -// `should have a group size of 1 but was ${ -// (await client.conversations.listGroups()).length -// }` -// ) - -// await client.dropLocalDatabaseConnection() - -// try { -// await group.send('hi') -// // eslint-disable-next-line @typescript-eslint/no-unused-vars -// } catch (error) { -// await client.reconnectLocalDatabase() -// await group.send('hi') -// return true -// } -// throw new Error('should throw when local database not connected') -// }) - -// test('can make a MLS V3 client from bundle', async () => { -// const key = new Uint8Array([ -// 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, -// 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, -// ]) - -// const client = await Client.createRandom({ -// env: 'local', -// appVersion: 'Testing/0.0.0', -// enableAlphaMls: true, -// dbEncryptionKey: key, -// }) - -// const anotherClient = await Client.createRandom({ -// env: 'local', -// appVersion: 'Testing/0.0.0', -// enableAlphaMls: true, -// dbEncryptionKey: key, -// }) - -// const group1 = await client.conversations.newGroup([anotherClient.address]) - -// assert( -// group1.client.address === client.address, -// `clients dont match ${client.address} and ${group1.client.address}` -// ) - -// const bundle = await client.exportKeyBundle() -// const client2 = await Client.createFromKeyBundle(bundle, { -// env: 'local', -// appVersion: 'Testing/0.0.0', -// enableAlphaMls: true, -// dbEncryptionKey: key, -// }) - -// assert( -// client.address === client2.address, -// `clients dont match ${client2.address} and ${client.address}` -// ) - -// assert( -// client.inboxId === client2.inboxId, -// `clients dont match ${client2.inboxId} and ${client.inboxId}` -// ) - -// assert( -// client.installationId === client2.installationId, -// `clients dont match ${client2.installationId} and ${client.installationId}` -// ) - -// const randomClient = await Client.createRandom({ -// env: 'local', -// appVersion: 'Testing/0.0.0', -// enableAlphaMls: true, -// dbEncryptionKey: key, -// }) - -// const group = await client2.conversations.newGroup([randomClient.address]) - -// assert( -// group.client.address === client2.address, -// `clients dont match ${client2.address} and ${group.client.address}` -// ) - -// return true -// }) - -// test('production MLS V3 client creation throws error', async () => { -// const key = new Uint8Array([ -// 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, -// 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, -// ]) - -// try { -// await Client.createRandom({ -// env: 'production', -// appVersion: 'Testing/0.0.0', -// enableAlphaMls: true, -// dbEncryptionKey: key, -// }) -// // eslint-disable-next-line @typescript-eslint/no-unused-vars -// } catch (error) { -// return true -// } -// throw new Error( -// 'should throw error on MLS V3 client create when environment is not local' -// ) -// }) - -// test('group message delivery status', async () => { -// const [alixClient, boClient] = await createClients(2) -// const alixGroup = await alixClient.conversations.newGroup([boClient.address]) - -// await alixGroup.send('hello, world') +test('can delete a local database', async () => { + let [client, anotherClient] = await createClients(2) -// const alixMessages: DecodedMessage[] = await alixGroup.messages() + await client.conversations.newGroup([anotherClient.address]) + await client.conversations.syncGroups() + assert( + (await client.conversations.listGroups()).length === 1, + `should have a group size of 1 but was ${ + (await client.conversations.listGroups()).length + }` + ) -// assert( -// alixMessages.length === 2, -// `the messages length should be 2 but was ${alixMessages.length}` -// ) + await client.deleteLocalDatabase() + client = await Client.createRandom({ + env: 'local', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, + dbEncryptionKey: new Uint8Array([ + 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, + 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, + 145, + ]), + }) + await client.conversations.syncGroups() + assert( + (await client.conversations.listGroups()).length === 0, + `should have a group size of 0 but was ${ + (await client.conversations.listGroups()).length + }` + ) -// const alixMessagesFiltered: DecodedMessage[] = await alixGroup.messages({ -// deliveryStatus: MessageDeliveryStatus.UNPUBLISHED, -// }) + return true +}) -// assert( -// alixMessagesFiltered.length === 1, -// `the messages length should be 1 but was ${alixMessagesFiltered.length}` -// ) +test('can make a MLS V3 client with encryption key and database directory', async () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const dbDirPath = `${RNFS.DocumentDirectoryPath}/xmtp_db` + const directoryExists = await RNFS.exists(dbDirPath) + if (!directoryExists) { + await RNFS.mkdir(dbDirPath) + } + const key = new Uint8Array([ + 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, + 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, + ]) + + const client = await Client.createRandom({ + env: 'local', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, + dbEncryptionKey: key, + dbDirectory: dbDirPath, + }) -// await alixGroup.sync() -// const alixMessages2: DecodedMessage[] = await alixGroup.messages() + const anotherClient = await Client.createRandom({ + env: 'local', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, + dbEncryptionKey: key, + }) -// assert( -// alixMessages2.length === 2, -// `the messages length should be 2 but was ${alixMessages.length}` -// ) + await client.conversations.newGroup([anotherClient.address]) + assert( + (await client.conversations.listGroups()).length === 1, + `should have a group size of 1 but was ${ + (await client.conversations.listGroups()).length + }` + ) -// assert( -// alixMessages2[0].deliveryStatus === 'PUBLISHED', -// `the message should have a delivery status of PUBLISHED but was ${alixMessages2[0].deliveryStatus}` -// ) + const bundle = await client.exportKeyBundle() + const clientFromBundle = await Client.createFromKeyBundle(bundle, { + env: 'local', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, + dbEncryptionKey: key, + dbDirectory: dbDirPath, + }) -// await boClient.conversations.syncGroups() -// const boGroup = (await boClient.conversations.listGroups())[0] -// await boGroup.sync() -// const boMessages: DecodedMessage[] = await boGroup.messages() + assert( + clientFromBundle.address === client.address, + `clients dont match ${client.address} and ${clientFromBundle.address}` + ) -// assert( -// boMessages.length === 1, -// `the messages length should be 1 but was ${boMessages.length}` -// ) + assert( + (await clientFromBundle.conversations.listGroups()).length === 1, + `should have a group size of 1 but was ${ + (await clientFromBundle.conversations.listGroups()).length + }` + ) + return true +}) -// assert( -// boMessages[0].deliveryStatus === 'PUBLISHED', -// `the message should have a delivery status of PUBLISHED but was ${boMessages[0].deliveryStatus}` -// ) +test('can drop a local database', async () => { + const [client, anotherClient] = await createClients(2) -// return true -// }) + const group = await client.conversations.newGroup([anotherClient.address]) + await client.conversations.syncGroups() + assert( + (await client.conversations.listGroups()).length === 1, + `should have a group size of 1 but was ${ + (await client.conversations.listGroups()).length + }` + ) -// test('who added me to a group', async () => { -// const [alixClient, boClient] = await createClients(2) -// await alixClient.conversations.newGroup([boClient.address]) + await client.dropLocalDatabaseConnection() + + try { + await group.send('hi') + // eslint-disable-next-line @typescript-eslint/no-unused-vars + } catch (error) { + await client.reconnectLocalDatabase() + await group.send('hi') + return true + } + throw new Error('should throw when local database not connected') +}) -// await boClient.conversations.syncGroups() -// const boGroup = (await boClient.conversations.listGroups())[0] -// const addedByInboxId = await boGroup.addedByInboxId() +test('can make a MLS V3 client from bundle', async () => { + const key = new Uint8Array([ + 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, + 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, + ]) + + const client = await Client.createRandom({ + env: 'local', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, + dbEncryptionKey: key, + }) -// assert( -// addedByInboxId === alixClient.inboxId, -// `addedByInboxId ${addedByInboxId} does not match ${alixClient.inboxId}` -// ) -// return true -// }) + const anotherClient = await Client.createRandom({ + env: 'local', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, + dbEncryptionKey: key, + }) -// test('can get members of a group', async () => { -// const [alixClient, boClient] = await createClients(2) -// const group = await alixClient.conversations.newGroup([boClient.address]) - -// const members = await group.members() - -// assert(members.length === 2, `Should be 2 members but was ${members.length}`) - -// // We can not be sure of the order that members will be returned in -// for (const member of members) { -// // Alix created the group so they are a super admin -// if ( -// member.addresses[0].toLocaleLowerCase() === -// alixClient.address.toLocaleLowerCase() -// ) { -// assert( -// member.permissionLevel === 'super_admin', -// `Should be super_admin but was ${member.permissionLevel}` -// ) -// } -// // Bo did not create the group so he defaults to permission level "member" -// if ( -// member.addresses[0].toLocaleLowerCase() === -// boClient.address.toLocaleLowerCase() -// ) { -// assert( -// member.permissionLevel === 'member', -// `Should be member but was ${member.permissionLevel}` -// ) -// } -// } -// return true -// }) + const group1 = await client.conversations.newGroup([anotherClient.address]) -// test('can message in a group', async () => { -// // Create three MLS enabled Clients -// const [alixClient, boClient, caroClient] = await createClients(3) + assert( + group1.client.address === client.address, + `clients dont match ${client.address} and ${group1.client.address}` + ) -// // alix's num groups start at 0 -// let alixGroups = await alixClient.conversations.listGroups() -// if (alixGroups.length !== 0) { -// throw new Error('num groups should be 0') -// } + const bundle = await client.exportKeyBundle() + const client2 = await Client.createFromKeyBundle(bundle, { + env: 'local', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, + dbEncryptionKey: key, + }) -// // alix creates a group -// const alixGroup = await alixClient.conversations.newGroup([ -// boClient.address, -// caroClient.address, -// ]) - -// // alix's num groups == 1 -// await alixClient.conversations.syncGroups() -// alixGroups = await alixClient.conversations.listGroups() -// if (alixGroups.length !== 1) { -// throw new Error('num groups should be 1') -// } + assert( + client.address === client2.address, + `clients dont match ${client2.address} and ${client.address}` + ) -// // alix group should match create time from list function -// assert(alixGroups[0].createdAt === alixGroup.createdAt, 'group create time') + assert( + client.inboxId === client2.inboxId, + `clients dont match ${client2.inboxId} and ${client.inboxId}` + ) -// // alix can confirm memberInboxIds -// await alixGroup.sync() -// const memberInboxIds = await alixGroup.memberInboxIds() -// if (memberInboxIds.length !== 3) { -// throw new Error('num group members should be 3') -// } -// const peerInboxIds = await alixGroup.peerInboxIds -// if (peerInboxIds.length !== 2) { -// throw new Error('num peer group members should be 2') -// } -// if ( -// !( -// memberInboxIds.includes(alixClient.inboxId) && -// memberInboxIds.includes(boClient.inboxId) && -// memberInboxIds.includes(caroClient.inboxId) -// ) -// ) { -// throw new Error('missing address') -// } + assert( + client.installationId === client2.installationId, + `clients dont match ${client2.installationId} and ${client.installationId}` + ) -// if ( -// !( -// peerInboxIds.includes(boClient.inboxId) && -// peerInboxIds.includes(caroClient.inboxId) -// ) -// ) { -// throw new Error('should include self') -// } + const randomClient = await Client.createRandom({ + env: 'local', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, + dbEncryptionKey: key, + }) -// // alix can send messages -// await alixGroup.send('hello, world') -// await alixGroup.send('gm') - -// // bo's num groups == 1 -// await boClient.conversations.syncGroups() -// const boGroups = await boClient.conversations.listGroups() -// if (boGroups.length !== 1) { -// throw new Error( -// 'num groups for bo should be 1, but it is' + boGroups.length -// ) -// } -// await delayToPropogate() -// // bo can read messages from alix -// await boGroups[0].sync() -// const boMessages: DecodedMessage[] = await boGroups[0].messages() - -// if (boMessages.length !== 2) { -// throw new Error( -// 'num messages for bo should be 2, but it is' + boMessages.length -// ) -// } -// if (boMessages[0].content() !== 'gm') { -// throw new Error("newest message should be 'gm'") -// } -// if (boMessages[1].content() !== 'hello, world') { -// throw new Error("newest message should be 'hello, world'") -// } -// // bo can send a message -// await boGroups[0].send('hey guys!') - -// // caro's num groups == 1 -// await caroClient.conversations.syncGroups() -// const caroGroups = await caroClient.conversations.listGroups() -// if (caroGroups.length !== 1) { -// throw new Error( -// 'num groups for caro should be 1, but it is' + caroGroups.length -// ) -// } + const group = await client2.conversations.newGroup([randomClient.address]) -// // caro can read messages from alix and bo -// await caroGroups[0].sync() -// const caroMessages = await caroGroups[0].messages() + assert( + group.client.address === client2.address, + `clients dont match ${client2.address} and ${group.client.address}` + ) -// if (caroMessages.length !== 3) { -// throw new Error(`length should be 3 but was ${caroMessages.length}`) -// } -// if (caroMessages[0].content() !== 'hey guys!') { -// throw new Error( -// `newest Message should be 'hey guys!' but was ${caroMessages[0].content()}` -// ) -// } -// if (caroMessages[1].content() !== 'gm') { -// throw new Error( -// `second Message should be 'gm' but was ${caroMessages[1].content()}` -// ) -// } + return true +}) -// return true -// }) +test('production MLS V3 client creation throws error', async () => { + const key = new Uint8Array([ + 233, 120, 198, 96, 154, 65, 132, 17, 132, 96, 250, 40, 103, 35, 125, 64, + 166, 83, 208, 224, 254, 44, 205, 227, 175, 49, 234, 129, 74, 252, 135, 145, + ]) + + try { + await Client.createRandom({ + env: 'production', + appVersion: 'Testing/0.0.0', + enableAlphaMls: true, + dbEncryptionKey: key, + }) + // eslint-disable-next-line @typescript-eslint/no-unused-vars + } catch (error) { + return true + } + throw new Error( + 'should throw error on MLS V3 client create when environment is not local' + ) +}) -// test('can add members to a group', async () => { -// // Create three MLS enabled Clients -// const [alixClient, boClient, caroClient] = await createClients(3) +test('group message delivery status', async () => { + const [alixClient, boClient] = await createClients(2) + const alixGroup = await alixClient.conversations.newGroup([boClient.address]) -// // alix's num groups start at 0 -// let alixGroups = await alixClient.conversations.listGroups() -// if (alixGroups.length !== 0) { -// throw new Error('num groups should be 0') -// } + await alixGroup.send('hello, world') -// // bo's num groups start at 0 -// let boGroups = await boClient.conversations.listGroups() -// if (boGroups.length !== 0) { -// throw new Error('num groups should be 0') -// } + const alixMessages: DecodedMessage[] = await alixGroup.messages() -// // caro's num groups start at 0 -// let caroGroups = await caroClient.conversations.listGroups() -// if (caroGroups.length !== 0) { -// throw new Error('num groups should be 0') -// } + assert( + alixMessages.length === 2, + `the messages length should be 2 but was ${alixMessages.length}` + ) -// // alix creates a group -// const alixGroup = await alixClient.conversations.newGroup([boClient.address]) + const alixMessagesFiltered: DecodedMessage[] = await alixGroup.messages({ + deliveryStatus: MessageDeliveryStatus.UNPUBLISHED, + }) -// // alix's num groups == 1 -// await alixClient.conversations.syncGroups() -// alixGroups = await alixClient.conversations.listGroups() -// if (alixGroups.length !== 1) { -// throw new Error('num groups should be 1') -// } + assert( + alixMessagesFiltered.length === 1, + `the messages length should be 1 but was ${alixMessagesFiltered.length}` + ) -// // alix can confirm memberInboxIds -// await alixGroup.sync() -// const memberInboxIds = await alixGroup.memberInboxIds() -// if (memberInboxIds.length !== 2) { -// throw new Error('num group members should be 2') -// } -// if ( -// !( -// memberInboxIds.includes(alixClient.inboxId) && -// memberInboxIds.includes(boClient.inboxId) -// ) -// ) { -// throw new Error('missing address') -// } + await alixGroup.sync() + const alixMessages2: DecodedMessage[] = await alixGroup.messages() -// // alix can send messages -// await alixGroup.send('hello, world') -// await alixGroup.send('gm') - -// // bo's num groups == 1 -// await boClient.conversations.syncGroups() -// boGroups = await boClient.conversations.listGroups() -// if (boGroups.length !== 1) { -// throw new Error( -// 'num groups for bo should be 1, but it is' + boGroups.length -// ) -// } + assert( + alixMessages2.length === 2, + `the messages length should be 2 but was ${alixMessages.length}` + ) -// await alixGroup.addMembers([caroClient.address]) + assert( + alixMessages2[0].deliveryStatus === 'PUBLISHED', + `the message should have a delivery status of PUBLISHED but was ${alixMessages2[0].deliveryStatus}` + ) -// // caro's num groups == 1 -// await caroClient.conversations.syncGroups() -// caroGroups = await caroClient.conversations.listGroups() -// if (caroGroups.length !== 1) { -// throw new Error( -// 'num groups for caro should be 1, but it is' + caroGroups.length -// ) -// } -// await caroGroups[0].sync() -// const caroMessages = await caroGroups[0].messages() -// if (caroMessages.length !== 0) { -// throw new Error('num messages for caro should be 0') -// } + await boClient.conversations.syncGroups() + const boGroup = (await boClient.conversations.listGroups())[0] + await boGroup.sync() + const boMessages: DecodedMessage[] = await boGroup.messages() -// await boGroups[0].sync() -// const boGroupMembers = await boGroups[0].memberInboxIds() -// if (boGroupMembers.length !== 3) { -// throw new Error('num group members should be 3') -// } + assert( + boMessages.length === 1, + `the messages length should be 1 but was ${boMessages.length}` + ) -// return true -// }) + assert( + boMessages[0].deliveryStatus === 'PUBLISHED', + `the message should have a delivery status of PUBLISHED but was ${boMessages[0].deliveryStatus}` + ) -// test('can remove members from a group', async () => { -// // Create three MLS enabled Clients -// const [alixClient, boClient, caroClient] = await createClients(3) + return true +}) -// // alix's num groups start at 0 -// let alixGroups = await alixClient.conversations.listGroups() -// if (alixGroups.length !== 0) { -// throw new Error('num groups should be 0') -// } +test('who added me to a group', async () => { + const [alixClient, boClient] = await createClients(2) + await alixClient.conversations.newGroup([boClient.address]) -// // bo's num groups start at 0 -// let boGroups = await boClient.conversations.listGroups() -// assert(boGroups.length === 0, 'num groups should be 0') + await boClient.conversations.syncGroups() + const boGroup = (await boClient.conversations.listGroups())[0] + const addedByInboxId = await boGroup.addedByInboxId() -// // caro's num groups start at 0 -// let caroGroups = await caroClient.conversations.listGroups() -// if (caroGroups.length !== 0) { -// throw new Error('num groups should be 0') -// } + assert( + addedByInboxId === alixClient.inboxId, + `addedByInboxId ${addedByInboxId} does not match ${alixClient.inboxId}` + ) + return true +}) -// // alix creates a group -// const alixGroup = await alixClient.conversations.newGroup([ -// boClient.address, -// caroClient.address, -// ]) - -// // alix's num groups == 1 -// await alixClient.conversations.syncGroups() -// alixGroups = await alixClient.conversations.listGroups() -// if (alixGroups.length !== 1) { -// throw new Error('num groups should be 1') -// } +test('can get members of a group', async () => { + const [alixClient, boClient] = await createClients(2) + const group = await alixClient.conversations.newGroup([boClient.address]) + + const members = await group.members() + + assert(members.length === 2, `Should be 2 members but was ${members.length}`) + + // We can not be sure of the order that members will be returned in + for (const member of members) { + // Alix created the group so they are a super admin + if ( + member.addresses[0].toLocaleLowerCase() === + alixClient.address.toLocaleLowerCase() + ) { + assert( + member.permissionLevel === 'super_admin', + `Should be super_admin but was ${member.permissionLevel}` + ) + } + // Bo did not create the group so he defaults to permission level "member" + if ( + member.addresses[0].toLocaleLowerCase() === + boClient.address.toLocaleLowerCase() + ) { + assert( + member.permissionLevel === 'member', + `Should be member but was ${member.permissionLevel}` + ) + } + } + return true +}) -// // alix can confirm memberInboxIds -// await alixGroup.sync() -// const memberInboxIds = await alixGroup.memberInboxIds() -// if (memberInboxIds.length !== 3) { -// throw new Error('num group members should be 3') -// } -// if ( -// !( -// memberInboxIds.includes(alixClient.inboxId) && -// memberInboxIds.includes(boClient.inboxId) -// ) -// ) { -// throw new Error('missing address') -// } +test('can message in a group', async () => { + // Create three MLS enabled Clients + const [alixClient, boClient, caroClient] = await createClients(3) + + // alix's num groups start at 0 + let alixGroups = await alixClient.conversations.listGroups() + if (alixGroups.length !== 0) { + throw new Error('num groups should be 0') + } + + // alix creates a group + const alixGroup = await alixClient.conversations.newGroup([ + boClient.address, + caroClient.address, + ]) + + // alix's num groups == 1 + await alixClient.conversations.syncGroups() + alixGroups = await alixClient.conversations.listGroups() + if (alixGroups.length !== 1) { + throw new Error('num groups should be 1') + } + + // alix group should match create time from list function + assert(alixGroups[0].createdAt === alixGroup.createdAt, 'group create time') + + // alix can confirm memberInboxIds + await alixGroup.sync() + const memberInboxIds = await alixGroup.memberInboxIds() + if (memberInboxIds.length !== 3) { + throw new Error('num group members should be 3') + } + const peerInboxIds = await alixGroup.peerInboxIds + if (peerInboxIds.length !== 2) { + throw new Error('num peer group members should be 2') + } + if ( + !( + memberInboxIds.includes(alixClient.inboxId) && + memberInboxIds.includes(boClient.inboxId) && + memberInboxIds.includes(caroClient.inboxId) + ) + ) { + throw new Error('missing address') + } + + if ( + !( + peerInboxIds.includes(boClient.inboxId) && + peerInboxIds.includes(caroClient.inboxId) + ) + ) { + throw new Error('should include self') + } + + // alix can send messages + await alixGroup.send('hello, world') + await alixGroup.send('gm') + + // bo's num groups == 1 + await boClient.conversations.syncGroups() + const boGroups = await boClient.conversations.listGroups() + if (boGroups.length !== 1) { + throw new Error( + 'num groups for bo should be 1, but it is' + boGroups.length + ) + } + await delayToPropogate() + // bo can read messages from alix + await boGroups[0].sync() + const boMessages: DecodedMessage[] = await boGroups[0].messages() + + if (boMessages.length !== 2) { + throw new Error( + 'num messages for bo should be 2, but it is' + boMessages.length + ) + } + if (boMessages[0].content() !== 'gm') { + throw new Error("newest message should be 'gm'") + } + if (boMessages[1].content() !== 'hello, world') { + throw new Error("newest message should be 'hello, world'") + } + // bo can send a message + await boGroups[0].send('hey guys!') + + // caro's num groups == 1 + await caroClient.conversations.syncGroups() + const caroGroups = await caroClient.conversations.listGroups() + if (caroGroups.length !== 1) { + throw new Error( + 'num groups for caro should be 1, but it is' + caroGroups.length + ) + } + + // caro can read messages from alix and bo + await caroGroups[0].sync() + const caroMessages = await caroGroups[0].messages() + + if (caroMessages.length !== 3) { + throw new Error(`length should be 3 but was ${caroMessages.length}`) + } + if (caroMessages[0].content() !== 'hey guys!') { + throw new Error( + `newest Message should be 'hey guys!' but was ${caroMessages[0].content()}` + ) + } + if (caroMessages[1].content() !== 'gm') { + throw new Error( + `second Message should be 'gm' but was ${caroMessages[1].content()}` + ) + } -// // alix can send messages -// await alixGroup.send('hello, world') -// await alixGroup.send('gm') - -// // bo's num groups == 1 -// await boClient.conversations.syncGroups() -// boGroups = await boClient.conversations.listGroups() -// if (boGroups.length !== 1) { -// throw new Error( -// 'num groups for bo should be 1, but it is' + boGroups.length -// ) -// } + return true +}) -// // caro's num groups == 1 -// await caroClient.conversations.syncGroups() -// caroGroups = await caroClient.conversations.listGroups() -// if (caroGroups.length !== 1) { -// throw new Error( -// 'num groups for caro should be 1, but it is' + caroGroups.length -// ) -// } +test('can add members to a group', async () => { + // Create three MLS enabled Clients + const [alixClient, boClient, caroClient] = await createClients(3) + + // alix's num groups start at 0 + let alixGroups = await alixClient.conversations.listGroups() + if (alixGroups.length !== 0) { + throw new Error('num groups should be 0') + } + + // bo's num groups start at 0 + let boGroups = await boClient.conversations.listGroups() + if (boGroups.length !== 0) { + throw new Error('num groups should be 0') + } + + // caro's num groups start at 0 + let caroGroups = await caroClient.conversations.listGroups() + if (caroGroups.length !== 0) { + throw new Error('num groups should be 0') + } + + // alix creates a group + const alixGroup = await alixClient.conversations.newGroup([boClient.address]) + + // alix's num groups == 1 + await alixClient.conversations.syncGroups() + alixGroups = await alixClient.conversations.listGroups() + if (alixGroups.length !== 1) { + throw new Error('num groups should be 1') + } + + // alix can confirm memberInboxIds + await alixGroup.sync() + const memberInboxIds = await alixGroup.memberInboxIds() + if (memberInboxIds.length !== 2) { + throw new Error('num group members should be 2') + } + if ( + !( + memberInboxIds.includes(alixClient.inboxId) && + memberInboxIds.includes(boClient.inboxId) + ) + ) { + throw new Error('missing address') + } + + // alix can send messages + await alixGroup.send('hello, world') + await alixGroup.send('gm') + + // bo's num groups == 1 + await boClient.conversations.syncGroups() + boGroups = await boClient.conversations.listGroups() + if (boGroups.length !== 1) { + throw new Error( + 'num groups for bo should be 1, but it is' + boGroups.length + ) + } + + await alixGroup.addMembers([caroClient.address]) + + // caro's num groups == 1 + await caroClient.conversations.syncGroups() + caroGroups = await caroClient.conversations.listGroups() + if (caroGroups.length !== 1) { + throw new Error( + 'num groups for caro should be 1, but it is' + caroGroups.length + ) + } + await caroGroups[0].sync() + const caroMessages = await caroGroups[0].messages() + if (caroMessages.length !== 0) { + throw new Error('num messages for caro should be 0') + } + + await boGroups[0].sync() + const boGroupMembers = await boGroups[0].memberInboxIds() + if (boGroupMembers.length !== 3) { + throw new Error('num group members should be 3') + } -// await caroGroups[0].sync() -// if (!caroGroups[0].isActive()) { -// throw new Error('caros group should be active') -// } + return true +}) -// await alixGroup.removeMembers([caroClient.address]) -// await alixGroup.sync() -// const alixGroupMembers = await alixGroup.memberInboxIds() -// if (alixGroupMembers.length !== 2) { -// throw new Error( -// 'num group members should be 2 but was' + alixGroupMembers.length -// ) -// } +test('can remove members from a group', async () => { + // Create three MLS enabled Clients + const [alixClient, boClient, caroClient] = await createClients(3) + + // alix's num groups start at 0 + let alixGroups = await alixClient.conversations.listGroups() + if (alixGroups.length !== 0) { + throw new Error('num groups should be 0') + } + + // bo's num groups start at 0 + let boGroups = await boClient.conversations.listGroups() + assert(boGroups.length === 0, 'num groups should be 0') + + // caro's num groups start at 0 + let caroGroups = await caroClient.conversations.listGroups() + if (caroGroups.length !== 0) { + throw new Error('num groups should be 0') + } + + // alix creates a group + const alixGroup = await alixClient.conversations.newGroup([ + boClient.address, + caroClient.address, + ]) + + // alix's num groups == 1 + await alixClient.conversations.syncGroups() + alixGroups = await alixClient.conversations.listGroups() + if (alixGroups.length !== 1) { + throw new Error('num groups should be 1') + } + + // alix can confirm memberInboxIds + await alixGroup.sync() + const memberInboxIds = await alixGroup.memberInboxIds() + if (memberInboxIds.length !== 3) { + throw new Error('num group members should be 3') + } + if ( + !( + memberInboxIds.includes(alixClient.inboxId) && + memberInboxIds.includes(boClient.inboxId) + ) + ) { + throw new Error('missing address') + } + + // alix can send messages + await alixGroup.send('hello, world') + await alixGroup.send('gm') + + // bo's num groups == 1 + await boClient.conversations.syncGroups() + boGroups = await boClient.conversations.listGroups() + if (boGroups.length !== 1) { + throw new Error( + 'num groups for bo should be 1, but it is' + boGroups.length + ) + } + + // caro's num groups == 1 + await caroClient.conversations.syncGroups() + caroGroups = await caroClient.conversations.listGroups() + if (caroGroups.length !== 1) { + throw new Error( + 'num groups for caro should be 1, but it is' + caroGroups.length + ) + } + + await caroGroups[0].sync() + if (!caroGroups[0].isActive()) { + throw new Error('caros group should be active') + } + + await alixGroup.removeMembers([caroClient.address]) + await alixGroup.sync() + const alixGroupMembers = await alixGroup.memberInboxIds() + if (alixGroupMembers.length !== 2) { + throw new Error( + 'num group members should be 2 but was' + alixGroupMembers.length + ) + } + + await caroGroups[0].sync() + if (await caroGroups[0].isActive()) { + throw new Error('caros group should not be active') + } + + const caroGroupMembers = await caroGroups[0].memberInboxIds() + // should be 3 since they wont get new updates to the group after being removed + if (caroGroupMembers.length !== 3) { + throw new Error( + 'num group members should be 3 but was' + caroGroupMembers.length + ) + } -// await caroGroups[0].sync() -// if (await caroGroups[0].isActive()) { -// throw new Error('caros group should not be active') -// } + return true +}) -// const caroGroupMembers = await caroGroups[0].memberInboxIds() -// // should be 3 since they wont get new updates to the group after being removed -// if (caroGroupMembers.length !== 3) { -// throw new Error( -// 'num group members should be 3 but was' + caroGroupMembers.length -// ) -// } +test('can remove and add members from a group by inbox id', async () => { + // Create three MLS enabled Clients + const [alixClient, boClient, caroClient] = await createClients(3) + + // alix creates a group + const alixGroup = await alixClient.conversations.newGroup([ + boClient.address, + caroClient.address, + ]) + + // alix can confirm memberInboxIds + await alixGroup.sync() + const memberInboxIds = await alixGroup.memberInboxIds() + if (memberInboxIds.length !== 3) { + throw new Error('num group members should be 3') + } + + await alixGroup.removeMembersByInboxId([caroClient.inboxId]) + await alixGroup.sync() + const alixGroupMembers = await alixGroup.memberInboxIds() + if (alixGroupMembers.length !== 2) { + throw new Error('num group members should be 2') + } + + await alixGroup.addMembersByInboxId([caroClient.inboxId]) + await alixGroup.sync() + const alixGroupMembers2 = await alixGroup.memberInboxIds() + if (alixGroupMembers2.length !== 3) { + throw new Error('num group members should be 3') + } -// return true -// }) + return true +}) -// test('can remove and add members from a group by inbox id', async () => { -// // Create three MLS enabled Clients -// const [alixClient, boClient, caroClient] = await createClients(3) - -// // alix creates a group -// const alixGroup = await alixClient.conversations.newGroup([ -// boClient.address, -// caroClient.address, -// ]) - -// // alix can confirm memberInboxIds -// await alixGroup.sync() -// const memberInboxIds = await alixGroup.memberInboxIds() -// if (memberInboxIds.length !== 3) { -// throw new Error('num group members should be 3') -// } +test('can stream both groups and messages at same time', async () => { + const [alix, bo] = await createClients(2) -// await alixGroup.removeMembersByInboxId([caroClient.inboxId]) -// await alixGroup.sync() -// const alixGroupMembers = await alixGroup.memberInboxIds() -// if (alixGroupMembers.length !== 2) { -// throw new Error('num group members should be 2') -// } + let groupCallbacks = 0 + let messageCallbacks = 0 + await bo.conversations.streamGroups(async () => { + groupCallbacks++ + }) -// await alixGroup.addMembersByInboxId([caroClient.inboxId]) -// await alixGroup.sync() -// const alixGroupMembers2 = await alixGroup.memberInboxIds() -// if (alixGroupMembers2.length !== 3) { -// throw new Error('num group members should be 3') -// } + await bo.conversations.streamAllMessages(async () => { + messageCallbacks++ + }, true) -// return true -// }) + const group = await alix.conversations.newGroup([bo.address]) + await group.send('hello') -// test('can stream groups', async () => { -// const [alixClient, boClient, caroClient] = await createClients(3) - -// // Start streaming groups -// const groups: Group[] = [] -// const cancelStreamGroups = await alixClient.conversations.streamGroups( -// async (group: Group) => { -// groups.push(group) -// } -// ) - -// // caro creates a group with alix, so stream callback is fired -// // eslint-disable-next-line @typescript-eslint/no-unused-vars -// const caroGroup = await caroClient.conversations.newGroup([ -// alixClient.address, -// ]) -// await delayToPropogate() -// if ((groups.length as number) !== 1) { -// throw Error('Unexpected num groups (should be 1): ' + groups.length) -// } + await delayToPropogate() + // await new Promise((resolve) => setTimeout(resolve, 10000)) + assert( + messageCallbacks === 1, + 'message stream should have received 1 message' + ) + assert(groupCallbacks === 1, 'group stream should have received 1 group') + return true +}) -// // bo creates a group with alix so a stream callback is fired -// // eslint-disable-next-line @typescript-eslint/no-unused-vars -// const boGroup = await boClient.conversations.newGroup([alixClient.address]) -// await delayToPropogate() -// if ((groups.length as number) !== 2) { -// throw Error('Unexpected num groups (should be 2): ' + groups.length) -// } +test('can stream groups', async () => { + const [alixClient, boClient, caroClient] = await createClients(3) -// // * Note alix creating a group does not trigger alix conversations -// // group stream. Workaround is to syncGroups after you create and list manually -// // See https://github.com/xmtp/libxmtp/issues/504 + // Start streaming groups + const groups: Group[] = [] + const cancelStreamGroups = await alixClient.conversations.streamGroups( + async (group: Group) => { + groups.push(group) + } + ) -// // alix creates a group -// // eslint-disable-next-line @typescript-eslint/no-unused-vars -// const alixGroup = await alixClient.conversations.newGroup([ -// boClient.address, -// caroClient.address, -// ]) -// await delayToPropogate() -// if (groups.length !== 2) { -// throw Error('Expected group length 2 but it is: ' + groups.length) -// } -// // Sync groups after creation if you created a group -// const listedGroups = await alixClient.conversations.listGroups() -// await delayToPropogate() -// groups.push(listedGroups[listedGroups.length - 1]) -// if ((groups.length as number) !== 3) { -// throw Error('Expected group length 3 but it is: ' + groups.length) -// } + // caro creates a group with alix, so stream callback is fired + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const caroGroup = await caroClient.conversations.newGroup([ + alixClient.address, + ]) + await delayToPropogate() + if ((groups.length as number) !== 1) { + throw Error('Unexpected num groups (should be 1): ' + groups.length) + } -// cancelStreamGroups() -// await delayToPropogate() + // bo creates a group with alix so a stream callback is fired + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const boGroup = await boClient.conversations.newGroup([alixClient.address]) + await delayToPropogate() + if ((groups.length as number) !== 2) { + throw Error('Unexpected num groups (should be 2): ' + groups.length) + } + + // * Note alix creating a group does not trigger alix conversations + // group stream. Workaround is to syncGroups after you create and list manually + // See https://github.com/xmtp/libxmtp/issues/504 + + // alix creates a group + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const alixGroup = await alixClient.conversations.newGroup([ + boClient.address, + caroClient.address, + ]) + await delayToPropogate() + if (groups.length !== 2) { + throw Error('Expected group length 2 but it is: ' + groups.length) + } + // Sync groups after creation if you created a group + const listedGroups = await alixClient.conversations.listGroups() + await delayToPropogate() + groups.push(listedGroups[listedGroups.length - 1]) + if ((groups.length as number) !== 3) { + throw Error('Expected group length 3 but it is: ' + groups.length) + } -// // Creating a group should no longer trigger stream groups -// // eslint-disable-next-line @typescript-eslint/no-unused-vars -// const caroSecond = await caroClient.conversations.newGroup([ -// alixClient.address, -// ]) -// await delayToPropogate() -// if ((groups.length as number) !== 3) { -// throw Error('Unexpected num groups (should be 3): ' + groups.length) -// } + cancelStreamGroups() + await delayToPropogate() -// return true -// }) + // Creating a group should no longer trigger stream groups + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const caroSecond = await caroClient.conversations.newGroup([ + alixClient.address, + ]) + await delayToPropogate() + if ((groups.length as number) !== 3) { + throw Error('Unexpected num groups (should be 3): ' + groups.length) + } -// test('can list all groups and conversations', async () => { -// const [alixClient, boClient, caroClient] = await createClients(3) - -// // Add one group and one conversation -// const boGroup = await boClient.conversations.newGroup([alixClient.address]) -// const alixConversation = await alixClient.conversations.newConversation( -// caroClient.address -// ) - -// const listedContainers = await alixClient.conversations.listAll() - -// // Verify information in listed containers is correct -// // BUG - List All returns in Chronological order on iOS -// // and reverse Chronological order on Android -// const first = isIos() ? 1 : 0 -// const second = isIos() ? 0 : 1 -// if ( -// listedContainers[first].topic !== boGroup.topic || -// listedContainers[first].version !== ConversationVersion.GROUP || -// listedContainers[second].version !== ConversationVersion.DIRECT || -// listedContainers[second].createdAt !== alixConversation.createdAt -// ) { -// throw Error('Listed containers should match streamed containers') -// } + return true +}) -// return true -// }) +test('can list all groups and conversations', async () => { + const [alixClient, boClient, caroClient] = await createClients(3) -// test('can stream all groups and conversations', async () => { -// const [alixClient, boClient, caroClient] = await createClients(3) + // Add one group and one conversation + const boGroup = await boClient.conversations.newGroup([alixClient.address]) + const alixConversation = await alixClient.conversations.newConversation( + caroClient.address + ) -// // Start streaming groups and conversations -// const containers: ConversationContainer[] = [] -// const cancelStreamAll = await alixClient.conversations.streamAll( -// async (conversationContainer: ConversationContainer) => { -// containers.push(conversationContainer) -// } -// ) + const listedContainers = await alixClient.conversations.listAll() + + // Verify information in listed containers is correct + // BUG - List All returns in Chronological order on iOS + // and reverse Chronological order on Android + const first = isIos() ? 1 : 0 + const second = isIos() ? 0 : 1 + if ( + listedContainers[first].topic !== boGroup.topic || + listedContainers[first].version !== ConversationVersion.GROUP || + listedContainers[second].version !== ConversationVersion.DIRECT || + listedContainers[second].createdAt !== alixConversation.createdAt + ) { + throw Error('Listed containers should match streamed containers') + } -// // bo creates a group with alix, so stream callback is fired -// // eslint-disable-next-line @typescript-eslint/no-unused-vars -// const boGroup = await boClient.conversations.newGroup([alixClient.address]) -// await delayToPropogate() -// if ((containers.length as number) !== 1) { -// throw Error('Unexpected num groups (should be 1): ' + containers.length) -// } + return true +}) -// // bo creates a v2 Conversation with alix so a stream callback is fired -// // eslint-disable-next-line @typescript-eslint/no-unused-vars -// const boConversation = await boClient.conversations.newConversation( -// alixClient.address -// ) -// await delayToPropogate() -// if ((containers.length as number) !== 2) { -// throw Error('Unexpected num groups (should be 2): ' + containers.length) -// } +test('can stream all groups and conversations', async () => { + const [alixClient, boClient, caroClient] = await createClients(3) -// if ( -// containers[1].version === ConversationVersion.DIRECT && -// boConversation.conversationID !== -// (containers[1] as Conversation).conversationID -// ) { -// throw Error( -// 'Conversation from streamed all should match conversationID with created conversation' -// ) -// } + // Start streaming groups and conversations + const containers: ConversationContainer[] = [] + const cancelStreamAll = await alixClient.conversations.streamAll( + async (conversationContainer: ConversationContainer) => { + containers.push(conversationContainer) + } + ) -// // * Note alix creating a v2 Conversation does trigger alix conversations -// // stream. + // bo creates a group with alix, so stream callback is fired + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const boGroup = await boClient.conversations.newGroup([alixClient.address]) + await delayToPropogate() + if ((containers.length as number) !== 1) { + throw Error('Unexpected num groups (should be 1): ' + containers.length) + } + + // bo creates a v2 Conversation with alix so a stream callback is fired + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const boConversation = await boClient.conversations.newConversation( + alixClient.address + ) + await delayToPropogate() + if ((containers.length as number) !== 2) { + throw Error('Unexpected num groups (should be 2): ' + containers.length) + } + + if ( + containers[1].version === ConversationVersion.DIRECT && + boConversation.conversationID !== + (containers[1] as Conversation).conversationID + ) { + throw Error( + 'Conversation from streamed all should match conversationID with created conversation' + ) + } + + // * Note alix creating a v2 Conversation does trigger alix conversations + // stream. + + // alix creates a V2 Conversationgroup + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const alixConversation = await alixClient.conversations.newConversation( + caroClient.address + ) + await delayToPropogate() + if (containers.length !== 3) { + throw Error('Expected group length 3 but it is: ' + containers.length) + } -// // alix creates a V2 Conversationgroup -// // eslint-disable-next-line @typescript-eslint/no-unused-vars -// const alixConversation = await alixClient.conversations.newConversation( -// caroClient.address -// ) -// await delayToPropogate() -// if (containers.length !== 3) { -// throw Error('Expected group length 3 but it is: ' + containers.length) -// } + cancelStreamAll() + await delayToPropogate() -// cancelStreamAll() -// await delayToPropogate() + // Creating a group should no longer trigger stream groups + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const caroConversation = await caroClient.conversations.newGroup([ + alixClient.address, + ]) + await delayToPropogate() + if ((containers.length as number) !== 3) { + throw Error('Unexpected num groups (should be 3): ' + containers.length) + } -// // Creating a group should no longer trigger stream groups -// // eslint-disable-next-line @typescript-eslint/no-unused-vars -// const caroConversation = await caroClient.conversations.newGroup([ -// alixClient.address, -// ]) -// await delayToPropogate() -// if ((containers.length as number) !== 3) { -// throw Error('Unexpected num groups (should be 3): ' + containers.length) -// } + return true +}) -// return true -// }) +test('canMessage', async () => { + const [bo, alix, caro] = await createClients(3) -// test('canMessage', async () => { -// const [bo, alix, caro] = await createClients(3) + const canMessage = await bo.canMessage(alix.address) + if (!canMessage) { + throw new Error('should be able to message v2 client') + } -// const canMessage = await bo.canMessage(alix.address) -// if (!canMessage) { -// throw new Error('should be able to message v2 client') -// } + const canMessageV3 = await caro.canGroupMessage([ + caro.address, + alix.address, + '0x0000000000000000000000000000000000000000', + ]) -// const canMessageV3 = await caro.canGroupMessage([ -// caro.address, -// alix.address, -// '0x0000000000000000000000000000000000000000', -// ]) + assert( + canMessageV3['0x0000000000000000000000000000000000000000'] === false, + `should not be able to message 0x0000000000000000000000000000000000000000` + ) -// assert( -// canMessageV3['0x0000000000000000000000000000000000000000'] === false, -// `should not be able to message 0x0000000000000000000000000000000000000000` -// ) + assert( + canMessageV3[caro.address.toLowerCase()] === true, + `should be able to message ${caro.address}` + ) -// assert( -// canMessageV3[caro.address.toLowerCase()] === true, -// `should be able to message ${caro.address}` -// ) + assert( + canMessageV3[alix.address.toLowerCase()] === true, + `should be able to message ${alix.address}` + ) -// assert( -// canMessageV3[alix.address.toLowerCase()] === true, -// `should be able to message ${alix.address}` -// ) + return true +}) -// return true -// }) +test('can stream group messages', async () => { + // Create three MLS enabled Clients + const [alixClient, boClient, caroClient] = await createClients(3) + + // alix creates a group + const alixGroup = await alixClient.conversations.newGroup([ + boClient.address, + caroClient.address, + ]) + + // Record message stream for this group + const groupMessages: DecodedMessage[] = [] + const cancelGroupMessageStream = await alixGroup.streamGroupMessages( + async (message) => { + groupMessages.push(message) + } + ) -// test('can stream group messages', async () => { -// // Create three MLS enabled Clients -// const [alixClient, boClient, caroClient] = await createClients(3) - -// // alix creates a group -// const alixGroup = await alixClient.conversations.newGroup([ -// boClient.address, -// caroClient.address, -// ]) - -// // Record message stream for this group -// const groupMessages: DecodedMessage[] = [] -// const cancelGroupMessageStream = await alixGroup.streamGroupMessages( -// async (message) => { -// groupMessages.push(message) -// } -// ) - -// // bo's num groups == 1 -// await boClient.conversations.syncGroups() -// const boGroup = (await boClient.conversations.listGroups())[0] - -// for (let i = 0; i < 5; i++) { -// await boGroup.send({ text: `Message ${i}` }) -// await delayToPropogate() -// } + // bo's num groups == 1 + await boClient.conversations.syncGroups() + const boGroup = (await boClient.conversations.listGroups())[0] + + for (let i = 0; i < 5; i++) { + await boGroup.send({ text: `Message ${i}` }) + await delayToPropogate() + } + + if (groupMessages.length !== 5) { + throw Error('Unexpected convo messages count ' + groupMessages.length) + } + for (let i = 0; i < 5; i++) { + if (groupMessages[i].content() !== `Message ${i}`) { + throw Error( + 'Unexpected group message content ' + groupMessages[i].content() + ) + } + } + + cancelGroupMessageStream() + for (let i = 0; i < 5; i++) { + await boGroup.send({ text: `Message ${i}` }) + } + + if (groupMessages.length !== 5) { + throw Error('Unexpected convo messages count ' + groupMessages.length) + } -// if (groupMessages.length !== 5) { -// throw Error('Unexpected convo messages count ' + groupMessages.length) -// } -// for (let i = 0; i < 5; i++) { -// if (groupMessages[i].content() !== `Message ${i}`) { -// throw Error( -// 'Unexpected group message content ' + groupMessages[i].content() -// ) -// } -// } + return true +}) -// cancelGroupMessageStream() -// for (let i = 0; i < 5; i++) { -// await boGroup.send({ text: `Message ${i}` }) -// } +test('can stream all messages', async () => { + const [alix, bo, caro] = await createClients(3) -// if (groupMessages.length !== 5) { -// throw Error('Unexpected convo messages count ' + groupMessages.length) -// } + await delayToPropogate() -// return true -// }) + // Record message stream across all conversations + const allMessages: DecodedMessage[] = [] + await alix.conversations.streamAllMessages(async (message) => { + allMessages.push(message) + }) -// test('can stream all messages', async () => { -// const [alix, bo, caro] = await createClients(3) + // Start bo starts a new conversation. + const boConvo = await bo.conversations.newConversation(alix.address) + await delayToPropogate() -// await delayToPropogate() + for (let i = 0; i < 5; i++) { + await boConvo.send({ text: `Message ${i}` }) + await delayToPropogate() + } -// // Record message stream across all conversations -// const allMessages: DecodedMessage[] = [] -// await alix.conversations.streamAllMessages(async (message) => { -// allMessages.push(message) -// }) + const count = allMessages.length + if (count !== 5) { + throw Error('Unexpected all messages count ' + allMessages.length) + } -// // Start bo starts a new conversation. -// const boConvo = await bo.conversations.newConversation(alix.address) -// await delayToPropogate() + const caroConvo = await caro.conversations.newConversation(alix.address) + const caroGroup = await caro.conversations.newGroup([alix.address]) + await delayToPropogate() + for (let i = 0; i < 5; i++) { + await caroConvo.send({ text: `Message ${i}` }) + await caroGroup.send({ text: `Message ${i}` }) + await delayToPropogate() + } -// for (let i = 0; i < 5; i++) { -// await boConvo.send({ text: `Message ${i}` }) -// await delayToPropogate() -// } + if (allMessages.length !== 10) { + throw Error('Unexpected all messages count ' + allMessages.length) + } -// const count = allMessages.length -// if (count !== 5) { -// throw Error('Unexpected all messages count ' + allMessages.length) -// } + alix.conversations.cancelStreamAllMessages() -// const caroConvo = await caro.conversations.newConversation(alix.address) -// const caroGroup = await caro.conversations.newGroup([alix.address]) -// await delayToPropogate() -// for (let i = 0; i < 5; i++) { -// await caroConvo.send({ text: `Message ${i}` }) -// await caroGroup.send({ text: `Message ${i}` }) -// await delayToPropogate() -// } + await alix.conversations.streamAllMessages(async (message) => { + allMessages.push(message) + }, true) -// if (allMessages.length !== 10) { -// throw Error('Unexpected all messages count ' + allMessages.length) -// } + for (let i = 0; i < 5; i++) { + await boConvo.send({ text: `Message ${i}` }) + await caroGroup.send({ text: `Message ${i}` }) + await delayToPropogate() + } + if (allMessages.length <= 15) { + throw Error('Unexpected all messages count ' + allMessages.length) + } -// alix.conversations.cancelStreamAllMessages() + return true +}) -// await alix.conversations.streamAllMessages(async (message) => { -// allMessages.push(message) -// }, true) +test('can make a group with admin permissions', async () => { + const [adminClient, anotherClient] = await createClients(2) -// for (let i = 0; i < 5; i++) { -// await boConvo.send({ text: `Message ${i}` }) -// await caroGroup.send({ text: `Message ${i}` }) -// await delayToPropogate() -// } -// if (allMessages.length <= 15) { -// throw Error('Unexpected all messages count ' + allMessages.length) -// } + const group = await adminClient.conversations.newGroup( + [anotherClient.address], + 'admin_only' + ) -// return true -// }) + if (group.permissionLevel !== 'admin_only') { + throw Error( + `Group permission level should be admin_only but was ${group.permissionLevel}` + ) + } -// test('can make a group with admin permissions', async () => { -// const [adminClient, anotherClient] = await createClients(2) + const isAdmin = await group.isAdmin(adminClient.inboxId) + if (!isAdmin) { + throw Error(`adminClient should be the admin`) + } -// const group = await adminClient.conversations.newGroup( -// [anotherClient.address], -// 'admin_only' -// ) + // Creator id not working, see https://github.com/xmtp/libxmtp/issues/788 + // if (group.creatorInboxId !== adminClient.inboxId) { + // throw Error( + // `adminClient should be the creator but was ${group.creatorInboxId}` + // ) + // } -// if (group.permissionLevel !== 'admin_only') { -// throw Error( -// `Group permission level should be admin_only but was ${group.permissionLevel}` -// ) -// } + return true +}) -// const isAdmin = await group.isAdmin(adminClient.inboxId) -// if (!isAdmin) { -// throw Error(`adminClient should be the admin`) -// } +test('can paginate group messages', async () => { + // Create three MLS enabled Clients + const [alixClient, boClient] = await createClients(2) -// // Creator id not working, see https://github.com/xmtp/libxmtp/issues/788 -// // if (group.creatorInboxId !== adminClient.inboxId) { -// // throw Error( -// // `adminClient should be the creator but was ${group.creatorInboxId}` -// // ) -// // } + // alix creates a group + const alixGroup = await alixClient.conversations.newGroup([boClient.address]) -// return true -// }) + // alix can send messages + await alixGroup.send('hello, world') + await alixGroup.send('gm') -// test('can paginate group messages', async () => { -// // Create three MLS enabled Clients -// const [alixClient, boClient] = await createClients(2) + await boClient.conversations.syncGroups() + const boGroups = await boClient.conversations.listGroups() + if (boGroups.length !== 1) { + throw new Error( + 'num groups for bo should be 1, but it is' + boGroups.length + ) + } + await delayToPropogate() + // bo can read messages from alix + await boGroups[0].sync() + const boMessages: DecodedMessage[] = await boGroups[0].messages({ + limit: 1, + }) -// // alix creates a group -// const alixGroup = await alixClient.conversations.newGroup([boClient.address]) + if (boMessages.length !== 1) { + throw Error(`Should limit just 1 message but was ${boMessages.length}`) + } -// // alix can send messages -// await alixGroup.send('hello, world') -// await alixGroup.send('gm') + return true +}) -// await boClient.conversations.syncGroups() -// const boGroups = await boClient.conversations.listGroups() -// if (boGroups.length !== 1) { -// throw new Error( -// 'num groups for bo should be 1, but it is' + boGroups.length -// ) -// } -// await delayToPropogate() -// // bo can read messages from alix -// await boGroups[0].sync() -// const boMessages: DecodedMessage[] = await boGroups[0].messages({ -// limit: 1, -// }) - -// if (boMessages.length !== 1) { -// throw Error(`Should limit just 1 message but was ${boMessages.length}`) -// } +test('can stream all group messages', async () => { + const [alix, bo, caro] = await createClients(3) -// return true -// }) + await delayToPropogate() -// test('can stream all group messages', async () => { -// const [alix, bo, caro] = await createClients(3) + // Start bo starts a new group. + const boGroup = await bo.conversations.newGroup([alix.address]) + await delayToPropogate() -// await delayToPropogate() + // Starts a new conversation. + const caroGroup = await caro.conversations.newGroup([alix.address]) -// // Start bo starts a new group. -// const boGroup = await bo.conversations.newGroup([alix.address]) -// await delayToPropogate() + // Record message stream across all conversations + const allMessages: DecodedMessage[] = [] + // If we don't call syncGroups here, the streamAllGroupMessages will not + // stream the first message. Feels like a bug. + await alix.conversations.syncGroups() + await alix.conversations.streamAllGroupMessages(async (message) => { + allMessages.push(message) + }) -// // Starts a new conversation. -// const caroGroup = await caro.conversations.newGroup([alix.address]) - -// // Record message stream across all conversations -// const allMessages: DecodedMessage[] = [] -// // If we don't call syncGroups here, the streamAllGroupMessages will not -// // stream the first message. Feels like a bug. -// await alix.conversations.syncGroups() -// await alix.conversations.streamAllGroupMessages(async (message) => { -// allMessages.push(message) -// }) - -// for (let i = 0; i < 5; i++) { -// await boGroup.send({ text: `Message ${i}` }) -// await delayToPropogate() -// } + for (let i = 0; i < 5; i++) { + await boGroup.send({ text: `Message ${i}` }) + await delayToPropogate() + } -// const count = allMessages.length -// if (count !== 5) { -// throw Error('Unexpected all messages count first' + allMessages.length) -// } + const count = allMessages.length + if (count !== 5) { + throw Error('Unexpected all messages count first' + allMessages.length) + } -// await delayToPropogate() -// for (let i = 0; i < 5; i++) { -// await caroGroup.send({ text: `Message ${i}` }) -// await delayToPropogate() -// } + await delayToPropogate() + for (let i = 0; i < 5; i++) { + await caroGroup.send({ text: `Message ${i}` }) + await delayToPropogate() + } -// if (allMessages.length !== 10) { -// throw Error('Unexpected all messages count second' + allMessages.length) -// } + if (allMessages.length !== 10) { + throw Error('Unexpected all messages count second' + allMessages.length) + } -// alix.conversations.cancelStreamAllGroupMessages() -// await delayToPropogate() -// await alix.conversations.streamAllGroupMessages(async (message) => { -// allMessages.push(message) -// }) + alix.conversations.cancelStreamAllGroupMessages() + await delayToPropogate() + await alix.conversations.streamAllGroupMessages(async (message) => { + allMessages.push(message) + }) -// for (let i = 0; i < 5; i++) { -// await boGroup.send({ text: `Message ${i}` }) -// await delayToPropogate() -// } -// if (allMessages.length <= 10) { -// throw Error('Unexpected all messages count ' + allMessages.length) -// } + for (let i = 0; i < 5; i++) { + await boGroup.send({ text: `Message ${i}` }) + await delayToPropogate() + } + if (allMessages.length <= 10) { + throw Error('Unexpected all messages count ' + allMessages.length) + } -// return true -// }) + return true +}) -// test('can streamAll from multiple clients', async () => { -// const [alix, bo, caro] = await createClients(3) +test('can streamAll from multiple clients', async () => { + const [alix, bo, caro] = await createClients(3) -// // Setup stream alls -// const allBoConversations: any[] = [] -// const allAliConversations: any[] = [] + // Setup stream alls + const allBoConversations: any[] = [] + const allAliConversations: any[] = [] -// await bo.conversations.streamAll(async (conversation) => { -// allBoConversations.push(conversation) -// }) -// await alix.conversations.streamAll(async (conversation) => { -// allAliConversations.push(conversation) -// }) + await bo.conversations.streamAll(async (conversation) => { + allBoConversations.push(conversation) + }) + await alix.conversations.streamAll(async (conversation) => { + allAliConversations.push(conversation) + }) -// // Start Caro starts a new conversation. -// await caro.conversations.newConversation(alix.address) -// await delayToPropogate() -// if (allBoConversations.length !== 0) { -// throw Error( -// 'Unexpected all conversations count for Bo ' + -// allBoConversations.length + -// ' and Alix had ' + -// allAliConversations.length -// ) -// } -// if (allAliConversations.length !== 1) { -// throw Error( -// 'Unexpected all conversations count ' + allAliConversations.length -// ) -// } -// return true -// }) + // Start Caro starts a new conversation. + await caro.conversations.newConversation(alix.address) + await delayToPropogate() + if (allBoConversations.length !== 0) { + throw Error( + 'Unexpected all conversations count for Bo ' + + allBoConversations.length + + ' and Alix had ' + + allAliConversations.length + ) + } + if (allAliConversations.length !== 1) { + throw Error( + 'Unexpected all conversations count ' + allAliConversations.length + ) + } + return true +}) -// test('can streamAll from multiple clients - swapped orderring', async () => { -// const [alix, bo, caro] = await createClients(3) +test('can streamAll from multiple clients - swapped orderring', async () => { + const [alix, bo, caro] = await createClients(3) -// // Setup stream alls -// const allBoConversations: any[] = [] -// const allAliConversations: any[] = [] + // Setup stream alls + const allBoConversations: any[] = [] + const allAliConversations: any[] = [] -// await alix.conversations.streamAll(async (conversation) => { -// allAliConversations.push(conversation) -// }) + await alix.conversations.streamAll(async (conversation) => { + allAliConversations.push(conversation) + }) -// await bo.conversations.streamAll(async (conversation) => { -// allBoConversations.push(conversation) -// }) + await bo.conversations.streamAll(async (conversation) => { + allBoConversations.push(conversation) + }) -// // Start Caro starts a new conversation. -// await caro.conversations.newConversation(alix.address) -// await delayToPropogate() -// if (allBoConversations.length !== 0) { -// throw Error( -// 'Unexpected all conversations count for Bo ' + -// allBoConversations.length + -// ' and Alix had ' + -// allAliConversations.length -// ) -// } -// if (allAliConversations.length !== 1) { -// throw Error( -// 'Unexpected all conversations count ' + allAliConversations.length -// ) -// } -// return true -// }) + // Start Caro starts a new conversation. + await caro.conversations.newConversation(alix.address) + await delayToPropogate() + if (allBoConversations.length !== 0) { + throw Error( + 'Unexpected all conversations count for Bo ' + + allBoConversations.length + + ' and Alix had ' + + allAliConversations.length + ) + } + if (allAliConversations.length !== 1) { + throw Error( + 'Unexpected all conversations count ' + allAliConversations.length + ) + } + return true +}) -// test('can streamAllMessages from multiple clients', async () => { -// const [alix, bo, caro] = await createClients(3) +test('can streamAllMessages from multiple clients', async () => { + const [alix, bo, caro] = await createClients(3) -// // Setup stream -// const allBoMessages: any[] = [] -// const allAliMessages: any[] = [] + // Setup stream + const allBoMessages: any[] = [] + const allAliMessages: any[] = [] -// await bo.conversations.streamAllMessages(async (conversation) => { -// allBoMessages.push(conversation) -// }, true) -// await alix.conversations.streamAllMessages(async (conversation) => { -// allAliMessages.push(conversation) -// }, true) + await bo.conversations.streamAllMessages(async (conversation) => { + allBoMessages.push(conversation) + }, true) + await alix.conversations.streamAllMessages(async (conversation) => { + allAliMessages.push(conversation) + }, true) -// // Start Caro starts a new conversation. -// const caroConversation = await caro.conversations.newConversation( -// alix.address -// ) -// await caroConversation.send({ text: `Message` }) -// await delayToPropogate() -// if (allBoMessages.length !== 0) { -// throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) -// } + // Start Caro starts a new conversation. + const caroConversation = await caro.conversations.newConversation( + alix.address + ) + await caroConversation.send({ text: `Message` }) + await delayToPropogate() + if (allBoMessages.length !== 0) { + throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) + } -// if (allAliMessages.length !== 1) { -// throw Error( -// 'Unexpected all conversations count for Ali ' + allAliMessages.length -// ) -// } + if (allAliMessages.length !== 1) { + throw Error( + 'Unexpected all conversations count for Ali ' + allAliMessages.length + ) + } -// return true -// }) + return true +}) -// test('can streamAllMessages from multiple clients - swapped', async () => { -// const [alix, bo, caro] = await createClients(3) +test('can streamAllMessages from multiple clients - swapped', async () => { + const [alix, bo, caro] = await createClients(3) -// // Setup stream -// const allBoMessages: any[] = [] -// const allAliMessages: any[] = [] -// const caroGroup = await caro.conversations.newGroup([alix.address]) + // Setup stream + const allBoMessages: any[] = [] + const allAliMessages: any[] = [] + const caroGroup = await caro.conversations.newGroup([alix.address]) -// await alix.conversations.streamAllMessages(async (conversation) => { -// allAliMessages.push(conversation) -// }, true) -// await bo.conversations.streamAllMessages(async (conversation) => { -// allBoMessages.push(conversation) -// }, true) + await alix.conversations.streamAllMessages(async (conversation) => { + allAliMessages.push(conversation) + }, true) + await bo.conversations.streamAllMessages(async (conversation) => { + allBoMessages.push(conversation) + }, true) -// // Start Caro starts a new conversation. -// const caroConvo = await caro.conversations.newConversation(alix.address) -// await delayToPropogate() -// await caroConvo.send({ text: `Message` }) -// await caroGroup.send({ text: `Message` }) -// await delayToPropogate() -// if (allBoMessages.length !== 0) { -// throw Error( -// 'Unexpected all conversations count for Bo ' + allBoMessages.length -// ) -// } + // Start Caro starts a new conversation. + const caroConvo = await caro.conversations.newConversation(alix.address) + await delayToPropogate() + await caroConvo.send({ text: `Message` }) + await caroGroup.send({ text: `Message` }) + await delayToPropogate() + if (allBoMessages.length !== 0) { + throw Error( + 'Unexpected all conversations count for Bo ' + allBoMessages.length + ) + } + + if (allAliMessages.length !== 2) { + throw Error( + 'Unexpected all conversations count for Ali ' + allAliMessages.length + ) + } -// if (allAliMessages.length !== 2) { -// throw Error( -// 'Unexpected all conversations count for Ali ' + allAliMessages.length -// ) -// } + return true +}) -// return true -// }) +test('can stream all group Messages from multiple clients', async () => { + const [alix, bo, caro] = await createClients(3) -// test('can stream all group Messages from multiple clients', async () => { -// const [alix, bo, caro] = await createClients(3) + // Setup stream + const allAlixMessages: DecodedMessage[] = [] + const allBoMessages: DecodedMessage[] = [] + const alixGroup = await caro.conversations.newGroup([alix.address]) + const boGroup = await caro.conversations.newGroup([bo.address]) -// // Setup stream -// const allAlixMessages: DecodedMessage[] = [] -// const allBoMessages: DecodedMessage[] = [] -// const alixGroup = await caro.conversations.newGroup([alix.address]) -// const boGroup = await caro.conversations.newGroup([bo.address]) + await alixGroup.streamGroupMessages(async (message) => { + allAlixMessages.push(message) + }) + await boGroup.streamGroupMessages(async (message) => { + allBoMessages.push(message) + }) -// await alixGroup.streamGroupMessages(async (message) => { -// allAlixMessages.push(message) -// }) -// await boGroup.streamGroupMessages(async (message) => { -// allBoMessages.push(message) -// }) + // Start Caro starts a new conversation. + await delayToPropogate() + await alixGroup.send({ text: `Message` }) + await delayToPropogate() + if (allBoMessages.length !== 0) { + throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) + } + + if (allAlixMessages.length !== 1) { + throw Error( + 'Unexpected all messages count for Ali ' + allAlixMessages.length + ) + } + + await alix.conversations.syncGroups() + const alixConv = (await alix.conversations.listGroups())[0] + await alixConv.send({ text: `Message` }) + await delayToPropogate() + if (allBoMessages.length !== 0) { + throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) + } + // @ts-ignore-next-line + if (allAlixMessages.length !== 2) { + throw Error( + 'Unexpected all messages count for Ali ' + allAlixMessages.length + ) + } -// // Start Caro starts a new conversation. -// await delayToPropogate() -// await alixGroup.send({ text: `Message` }) -// await delayToPropogate() -// if (allBoMessages.length !== 0) { -// throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) -// } + return true +}) -// if (allAlixMessages.length !== 1) { -// throw Error( -// 'Unexpected all messages count for Ali ' + allAlixMessages.length -// ) -// } +test('can stream all group Messages from multiple clients - swapped', async () => { + const [alix, bo, caro] = await createClients(3) -// await alix.conversations.syncGroups() -// const alixConv = (await alix.conversations.listGroups())[0] -// await alixConv.send({ text: `Message` }) -// await delayToPropogate() -// if (allBoMessages.length !== 0) { -// throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) -// } -// // @ts-ignore-next-line -// if (allAlixMessages.length !== 2) { -// throw Error( -// 'Unexpected all messages count for Ali ' + allAlixMessages.length -// ) -// } + // Setup stream + const allAlixMessages: DecodedMessage[] = [] + const allBoMessages: DecodedMessage[] = [] + const alixGroup = await caro.conversations.newGroup([alix.address]) + const boGroup = await caro.conversations.newGroup([bo.address]) -// return true -// }) + await boGroup.streamGroupMessages(async (message) => { + allBoMessages.push(message) + }) + await alixGroup.streamGroupMessages(async (message) => { + allAlixMessages.push(message) + }) -// test('can stream all group Messages from multiple clients - swapped', async () => { -// const [alix, bo, caro] = await createClients(3) + // Start Caro starts a new conversation. + await delayToPropogate() + await alixGroup.send({ text: `Message` }) + await delayToPropogate() + if (allBoMessages.length !== 0) { + throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) + } + + if (allAlixMessages.length !== 1) { + throw Error( + 'Unexpected all messages count for Ali ' + allAlixMessages.length + ) + } + + await alix.conversations.syncGroups() + const alixConv = (await alix.conversations.listGroups())[0] + await alixConv.send({ text: `Message` }) + await delayToPropogate() + if (allBoMessages.length !== 0) { + throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) + } + // @ts-ignore-next-line + if (allAlixMessages.length !== 2) { + throw Error( + 'Unexpected all messages count for Ali ' + allAlixMessages.length + ) + } -// // Setup stream -// const allAlixMessages: DecodedMessage[] = [] -// const allBoMessages: DecodedMessage[] = [] -// const alixGroup = await caro.conversations.newGroup([alix.address]) -// const boGroup = await caro.conversations.newGroup([bo.address]) + return true +}) -// await boGroup.streamGroupMessages(async (message) => { -// allBoMessages.push(message) -// }) -// await alixGroup.streamGroupMessages(async (message) => { -// allAlixMessages.push(message) -// }) +test('creating a group should allow group', async () => { + const [alix, bo] = await createClients(2) -// // Start Caro starts a new conversation. -// await delayToPropogate() -// await alixGroup.send({ text: `Message` }) -// await delayToPropogate() -// if (allBoMessages.length !== 0) { -// throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) -// } + const group = await alix.conversations.newGroup([bo.address]) + const consent = await alix.contacts.isGroupAllowed(group.id) + const groupConsent = await group.isAllowed() -// if (allAlixMessages.length !== 1) { -// throw Error( -// 'Unexpected all messages count for Ali ' + allAlixMessages.length -// ) -// } + if (!consent || !groupConsent) { + throw Error('Group should be allowed') + } -// await alix.conversations.syncGroups() -// const alixConv = (await alix.conversations.listGroups())[0] -// await alixConv.send({ text: `Message` }) -// await delayToPropogate() -// if (allBoMessages.length !== 0) { -// throw Error('Unexpected all messages count for Bo ' + allBoMessages.length) -// } -// // @ts-ignore-next-line -// if (allAlixMessages.length !== 2) { -// throw Error( -// 'Unexpected all messages count for Ali ' + allAlixMessages.length -// ) -// } + const state = await group.consentState() + assert( + state === 'allowed', + `the message should have a consent state of allowed but was ${state}` + ) -// return true -// }) + const consentList = await alix.contacts.consentList() + assert( + consentList[0].permissionType === 'allowed', + `the message should have a consent state of allowed but was ${consentList[0].permissionType}` + ) -// test('creating a group should allow group', async () => { -// const [alix, bo] = await createClients(2) + return true +}) -// const group = await alix.conversations.newGroup([bo.address]) -// const consent = await alix.contacts.isGroupAllowed(group.id) -// const groupConsent = await group.isAllowed() +test('can allow a group', async () => { + const [alix, bo] = await createClients(2) + const alixGroup = await alix.conversations.newGroup([bo.address]) + const startConsent = await bo.contacts.isGroupAllowed(alixGroup.id) + if (startConsent) { + throw Error('Group should not be allowed') + } + await bo.contacts.allowGroups([alixGroup.id]) + const isAllowed = await bo.contacts.isGroupAllowed(alixGroup.id) + if (!isAllowed) { + throw Error('Group should be allowed') + } -// if (!consent || !groupConsent) { -// throw Error('Group should be allowed') -// } + return true +}) -// const state = await group.consentState() -// assert( -// state === 'allowed', -// `the message should have a consent state of allowed but was ${state}` -// ) +test('can deny a group', async () => { + const [alix, bo] = await createClients(2) + const alixGroup = await alix.conversations.newGroup([bo.address]) + const startConsent = await bo.contacts.isGroupDenied(alixGroup.id) + if (startConsent) { + throw Error('Group should be unknown') + } + await bo.contacts.denyGroups([alixGroup.id]) + await bo.conversations.syncGroups() + const boGroups = await bo.conversations.listGroups() + const isDenied = await bo.contacts.isGroupDenied(alixGroup.id) + const isGroupDenied = await boGroups[0].isDenied() + if (!isDenied || !isGroupDenied) { + throw Error('Group should be denied') + } + await bo.contacts.allowGroups([alixGroup.id]) + const isAllowed = await bo.contacts.isGroupAllowed(alixGroup.id) + if (!isAllowed) { + throw Error('Group should be allowed') + } -// const consentList = await alix.contacts.consentList() -// assert( -// consentList[0].permissionType === 'allowed', -// `the message should have a consent state of allowed but was ${consentList[0].permissionType}` -// ) + return true +}) -// return true -// }) +test('can allow and deny a inbox id', async () => { + const [alix, bo] = await createClients(2) + const startConsent = await bo.contacts.isInboxAllowed(alix.inboxId) + if (startConsent) { + throw Error('inbox id should be unknown') + } + await bo.contacts.denyInboxes([alix.inboxId]) + const isDenied = await bo.contacts.isInboxDenied(alix.inboxId) + if (!isDenied) { + throw Error('inbox id should be denied') + } + await bo.contacts.allowInboxes([alix.inboxId]) + const isAllowed = await bo.contacts.isInboxAllowed(alix.inboxId) + if (!isAllowed) { + throw Error('inbox id should be allowed') + } + + const consentList = await bo.contacts.consentList() + assert( + consentList[0].entryType === 'inbox_id', + `the message should have a type of inbox_id but was ${consentList[0].entryType}` + ) -// test('can allow a group', async () => { -// const [alix, bo] = await createClients(2) -// const alixGroup = await alix.conversations.newGroup([bo.address]) -// const startConsent = await bo.contacts.isGroupAllowed(alixGroup.id) -// if (startConsent) { -// throw Error('Group should not be allowed') -// } -// await bo.contacts.allowGroups([alixGroup.id]) -// const isAllowed = await bo.contacts.isGroupAllowed(alixGroup.id) -// if (!isAllowed) { -// throw Error('Group should be allowed') -// } + return true +}) -// return true -// }) +test('can check if group is allowed', async () => { + const [alix, bo] = await createClients(2) + const alixGroup = await alix.conversations.newGroup([bo.address]) + const startConsent = await bo.contacts.isGroupAllowed(alixGroup.id) + if (startConsent) { + throw Error('Group should not be allowed by default') + } + await bo.contacts.allowGroups([alixGroup.id]) + const consent = await bo.contacts.isGroupAllowed(alixGroup.id) + if (!consent) { + throw Error('Group should be allowed') + } -// test('can deny a group', async () => { -// const [alix, bo] = await createClients(2) -// const alixGroup = await alix.conversations.newGroup([bo.address]) -// const startConsent = await bo.contacts.isGroupDenied(alixGroup.id) -// if (startConsent) { -// throw Error('Group should be unknown') -// } -// await bo.contacts.denyGroups([alixGroup.id]) -// await bo.conversations.syncGroups() -// const boGroups = await bo.conversations.listGroups() -// const isDenied = await bo.contacts.isGroupDenied(alixGroup.id) -// const isGroupDenied = await boGroups[0].isDenied() -// if (!isDenied || !isGroupDenied) { -// throw Error('Group should be denied') -// } -// await bo.contacts.allowGroups([alixGroup.id]) -// const isAllowed = await bo.contacts.isGroupAllowed(alixGroup.id) -// if (!isAllowed) { -// throw Error('Group should be allowed') -// } + return true +}) -// return true -// }) +test('can check if group is denied', async () => { + const [alix, bo] = await createClients(2) + const alixGroup = await alix.conversations.newGroup([bo.address]) + const startConsent = await bo.contacts.isGroupDenied(alixGroup.id) + if (startConsent) { + throw Error('Group should not be denied by default') + } + await bo.contacts.denyGroups([alixGroup.id]) + const consent = await bo.contacts.isGroupDenied(alixGroup.id) + if (!consent) { + throw Error('Group should be denied') + } + return true +}) -// test('can allow and deny a inbox id', async () => { -// const [alix, bo] = await createClients(2) -// const startConsent = await bo.contacts.isInboxAllowed(alix.inboxId) -// if (startConsent) { -// throw Error('inbox id should be unknown') -// } -// await bo.contacts.denyInboxes([alix.inboxId]) -// const isDenied = await bo.contacts.isInboxDenied(alix.inboxId) -// if (!isDenied) { -// throw Error('inbox id should be denied') -// } -// await bo.contacts.allowInboxes([alix.inboxId]) -// const isAllowed = await bo.contacts.isInboxAllowed(alix.inboxId) -// if (!isAllowed) { -// throw Error('inbox id should be allowed') -// } +test('sync function behaves as expected', async () => { + const [alix, bo, caro] = await createClients(3) + const alixGroup = await alix.conversations.newGroup([bo.address]) -// const consentList = await bo.contacts.consentList() -// assert( -// consentList[0].entryType === 'inbox_id', -// `the message should have a type of inbox_id but was ${consentList[0].entryType}` -// ) + await alixGroup.send({ text: 'hello' }) -// return true -// }) + // List groups will return empty until the first sync + let boGroups = await bo.conversations.listGroups() + assert(boGroups.length === 0, 'num groups for bo is 0 until we sync') -// test('can check if group is allowed', async () => { -// const [alix, bo] = await createClients(2) -// const alixGroup = await alix.conversations.newGroup([bo.address]) -// const startConsent = await bo.contacts.isGroupAllowed(alixGroup.id) -// if (startConsent) { -// throw Error('Group should not be allowed by default') -// } -// await bo.contacts.allowGroups([alixGroup.id]) -// const consent = await bo.contacts.isGroupAllowed(alixGroup.id) -// if (!consent) { -// throw Error('Group should be allowed') -// } + await bo.conversations.syncGroups() -// return true -// }) + boGroups = await bo.conversations.listGroups() + assert(boGroups.length === 1, 'num groups for bo is 1') -// test('can check if group is denied', async () => { -// const [alix, bo] = await createClients(2) -// const alixGroup = await alix.conversations.newGroup([bo.address]) -// const startConsent = await bo.contacts.isGroupDenied(alixGroup.id) -// if (startConsent) { -// throw Error('Group should not be denied by default') -// } -// await bo.contacts.denyGroups([alixGroup.id]) -// const consent = await bo.contacts.isGroupDenied(alixGroup.id) -// if (!consent) { -// throw Error('Group should be denied') -// } -// return true -// }) + // Num members will include the initial num of members even before sync + let numMembers = (await boGroups[0].memberInboxIds()).length + assert(numMembers === 2, 'num members should be 2') -// test('sync function behaves as expected', async () => { -// const [alix, bo, caro] = await createClients(3) -// const alixGroup = await alix.conversations.newGroup([bo.address]) + // Num messages for a group will be 0 until we sync the group + let numMessages = (await boGroups[0].messages()).length + assert(numMessages === 0, 'num members should be 1') -// await alixGroup.send({ text: 'hello' }) + await bo.conversations.syncGroups() -// // List groups will return empty until the first sync -// let boGroups = await bo.conversations.listGroups() -// assert(boGroups.length === 0, 'num groups for bo is 0 until we sync') + // Num messages is still 0 because we didnt sync the group itself + numMessages = (await boGroups[0].messages()).length + assert(numMessages === 0, 'num messages should be 0') -// await bo.conversations.syncGroups() + await boGroups[0].sync() -// boGroups = await bo.conversations.listGroups() -// assert(boGroups.length === 1, 'num groups for bo is 1') + // after syncing the group we now see the correct number of messages + numMessages = (await boGroups[0].messages()).length + assert(numMessages === 1, 'num members should be 1') -// // Num members will include the initial num of members even before sync -// let numMembers = (await boGroups[0].memberInboxIds()).length -// assert(numMembers === 2, 'num members should be 2') + await alixGroup.addMembers([caro.address]) -// // Num messages for a group will be 0 until we sync the group -// let numMessages = (await boGroups[0].messages()).length -// assert(numMessages === 0, 'num members should be 1') + numMembers = (await boGroups[0].memberInboxIds()).length + assert(numMembers === 2, 'num members should be 2') -// await bo.conversations.syncGroups() + await bo.conversations.syncGroups() -// // Num messages is still 0 because we didnt sync the group itself -// numMessages = (await boGroups[0].messages()).length -// assert(numMessages === 0, 'num messages should be 0') + // Even though we synced the groups, we need to sync the group itself to see the new member + numMembers = (await boGroups[0].memberInboxIds()).length + assert(numMembers === 2, 'num members should be 2') -// await boGroups[0].sync() + await boGroups[0].sync() -// // after syncing the group we now see the correct number of messages -// numMessages = (await boGroups[0].messages()).length -// assert(numMessages === 1, 'num members should be 1') + numMembers = (await boGroups[0].memberInboxIds()).length + assert(numMembers === 3, 'num members should be 3') -// await alixGroup.addMembers([caro.address]) + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const _alixGroup2 = await alix.conversations.newGroup([ + bo.address, + caro.address, + ]) + await bo.conversations.syncGroups() + boGroups = await bo.conversations.listGroups() + assert(boGroups.length === 2, 'num groups for bo is 2') -// numMembers = (await boGroups[0].memberInboxIds()).length -// assert(numMembers === 2, 'num members should be 2') + // Even before syncing the group, syncGroups will return the initial number of members + numMembers = (await boGroups[1].memberInboxIds()).length + assert(numMembers === 3, 'num members should be 3') -// await bo.conversations.syncGroups() + return true +}) -// // Even though we synced the groups, we need to sync the group itself to see the new member -// numMembers = (await boGroups[0].memberInboxIds()).length -// assert(numMembers === 2, 'num members should be 2') +test('can read and update group name', async () => { + const [alix, bo, caro] = await createClients(3) + const alixGroup = await alix.conversations.newGroup([bo.address]) -// await boGroups[0].sync() + await alixGroup.sync() + let groupName = await alixGroup.groupName() -// numMembers = (await boGroups[0].memberInboxIds()).length -// assert(numMembers === 3, 'num members should be 3') + assert(groupName === '', 'group name should be empty string') -// // eslint-disable-next-line @typescript-eslint/no-unused-vars -// const _alixGroup2 = await alix.conversations.newGroup([ -// bo.address, -// caro.address, -// ]) -// await bo.conversations.syncGroups() -// boGroups = await bo.conversations.listGroups() -// assert(boGroups.length === 2, 'num groups for bo is 2') + await alixGroup.updateGroupName('Test name update 1') -// // Even before syncing the group, syncGroups will return the initial number of members -// numMembers = (await boGroups[1].memberInboxIds()).length -// assert(numMembers === 3, 'num members should be 3') + await alixGroup.sync() + groupName = await alixGroup.groupName() -// return true -// }) + assert( + groupName === 'Test name update 1', + 'group name should be "Test name update 1"' + ) -// test('can read and update group name', async () => { -// const [alix, bo, caro] = await createClients(3) -// const alixGroup = await alix.conversations.newGroup([bo.address]) + await bo.conversations.syncGroups() + const boGroup = (await bo.conversations.listGroups())[0] + groupName = await boGroup.groupName() -// await alixGroup.sync() -// let groupName = await alixGroup.groupName() + assert(groupName === '', 'group name should be empty string') -// assert(groupName === '', 'group name should be empty string') + await boGroup.sync() -// await alixGroup.updateGroupName('Test name update 1') + groupName = await boGroup.groupName() -// await alixGroup.sync() -// groupName = await alixGroup.groupName() + assert( + groupName === 'Test name update 1', + 'group name should be "Test name update 1"' + ) -// assert( -// groupName === 'Test name update 1', -// 'group name should be "Test name update 1"' -// ) + await alixGroup.addMembers([caro.address]) + await caro.conversations.syncGroups() + const caroGroup = (await caro.conversations.listGroups())[0] -// await bo.conversations.syncGroups() -// const boGroup = (await bo.conversations.listGroups())[0] -// groupName = await boGroup.groupName() + await caroGroup.sync() + groupName = await caroGroup.groupName() + assert( + groupName === 'Test name update 1', + 'group name should be "Test name update 1"' + ) + return true +}) -// assert(groupName === '', 'group name should be empty string') +// 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', enableAlphaMls: true }) +// await delayToPropogate() +// const alix = await Client.createRandom({ env: 'local', enableAlphaMls: true }) +// await delayToPropogate() +// const caro = await Client.createRandom({ env: 'local', enableAlphaMls: true }) +// await delayToPropogate() -// await boGroup.sync() +// // Setup stream alls +// const allBoMessages: any[] = [] +// const allAliMessages: any[] = [] -// groupName = await boGroup.groupName() +// const group = await caro.conversations.newGroup([alix.address]) +// await bo.conversations.streamAllMessages(async (conversation) => { +// allBoMessages.push(conversation) +// }, true) +// await alix.conversations.streamAllMessages(async (conversation) => { +// allAliMessages.push(conversation) +// }, true) -// assert( -// groupName === 'Test name update 1', -// 'group name should be "Test name update 1"' -// ) +// // Wait for 15 minutes +// await delayToPropogate(15 * 1000 * 60) -// await alixGroup.addMembers([caro.address]) -// await caro.conversations.syncGroups() -// const caroGroup = (await caro.conversations.listGroups())[0] +// // Start Caro starts a new conversation. +// const convo = await caro.conversations.newConversation(alix.address) +// await group.send({ text: 'hello' }) +// await convo.send({ text: 'hello' }) +// await delayToPropogate() +// if (allBoMessages.length !== 0) { +// throw Error('Unexpected all conversations count ' + allBoMessages.length) +// } +// if (allAliMessages.length !== 2) { +// throw Error('Unexpected all conversations count ' + allAliMessages.length) +// } -// await caroGroup.sync() -// groupName = await caroGroup.groupName() -// assert( -// groupName === 'Test name update 1', -// 'group name should be "Test name update 1"' -// ) // 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', enableAlphaMls: true }) -// // await delayToPropogate() -// // const alix = await Client.createRandom({ env: 'local', enableAlphaMls: true }) -// // await delayToPropogate() -// // const caro = await Client.createRandom({ env: 'local', enableAlphaMls: true }) -// // await delayToPropogate() - -// // // Setup stream alls -// // const allBoMessages: any[] = [] -// // const allAliMessages: any[] = [] - -// // const group = await caro.conversations.newGroup([alix.address]) -// // await bo.conversations.streamAllMessages(async (conversation) => { -// // allBoMessages.push(conversation) -// // }, true) -// // await alix.conversations.streamAllMessages(async (conversation) => { -// // allAliMessages.push(conversation) -// // }, true) - -// // // Wait for 15 minutes -// // await delayToPropogate(15 * 1000 * 60) - -// // // Start Caro starts a new conversation. -// // const convo = await caro.conversations.newConversation(alix.address) -// // await group.send({ text: 'hello' }) -// // await convo.send({ text: 'hello' }) -// // await delayToPropogate() -// // if (allBoMessages.length !== 0) { -// // throw Error('Unexpected all conversations count ' + allBoMessages.length) -// // } -// // if (allAliMessages.length !== 2) { -// // throw Error('Unexpected all conversations count ' + allAliMessages.length) -// // } - -// // return true -// // }) diff --git a/ios/XMTPReactNative.podspec b/ios/XMTPReactNative.podspec index a84d0f4a8..2f02bee6b 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.11.5" + s.dependency "XMTP", "= 0.11.6" end From a78a928bc17153e58bde61f443d723134cdd3eb1 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 12 Jun 2024 23:47:00 -0700 Subject: [PATCH 3/3] fix: ios streaming conflicts --- example/src/tests/test-utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/src/tests/test-utils.ts b/example/src/tests/test-utils.ts index eb09f263d..417988969 100644 --- a/example/src/tests/test-utils.ts +++ b/example/src/tests/test-utils.ts @@ -10,7 +10,7 @@ export function isIos() { return Platform.OS === 'ios' } -export async function delayToPropogate(milliseconds = 1000): Promise { +export async function delayToPropogate(milliseconds = 100): Promise { // delay avoid clobbering return new Promise((r) => setTimeout(r, milliseconds)) }