From a927f3d8ca58ea95b7a50cd85401e0f4739abf24 Mon Sep 17 00:00:00 2001 From: Pat Nakajima <patnakajima@gmail.com> Date: Tue, 28 Nov 2023 10:56:20 -0800 Subject: [PATCH] fix tests --- example/ios/Podfile.lock | 40 ++++++++++++++------------------------- example/package-lock.json | 21 ++++---------------- example/package.json | 2 -- example/src/tests.ts | 28 ++++++++++++++++++++------- 4 files changed, 39 insertions(+), 52 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 42159e68d..a548ba9c8 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -12,14 +12,14 @@ PODS: - ExpoModulesCore - EXFont (11.1.1): - ExpoModulesCore - - EXImageLoader (4.3.0): + - EXImageLoader (4.4.0): - ExpoModulesCore - React-Core - - Expo (48.0.20): + - Expo (48.0.21): - ExpoModulesCore - - ExpoDocumentPicker (11.5.4): + - ExpoDocumentPicker (11.7.0): - ExpoModulesCore - - ExpoImagePicker (14.3.2): + - ExpoImagePicker (14.5.0): - ExpoModulesCore - ExpoKeepAwake (12.0.1): - ExpoModulesCore @@ -302,17 +302,13 @@ PODS: - React-jsinspector (0.71.8) - React-logger (0.71.8): - glog - - react-native-blob-util (0.19.0): + - react-native-blob-util (0.19.4): - React-Core - react-native-encrypted-storage (4.0.3): - React-Core - - react-native-get-random-values (1.8.0): - - React-Core - - react-native-mmkv (2.8.0): + - react-native-mmkv (2.11.0): - MMKV (>= 1.2.13) - React-Core - - react-native-randombytes (3.6.1): - - React-Core - react-native-safe-area-context (4.5.0): - RCT-Folly - RCTRequired @@ -406,7 +402,7 @@ PODS: - RNScreens (3.20.0): - React-Core - React-RCTImage - - RNSVG (13.9.0): + - RNSVG (13.14.0): - React-Core - secp256k1.swift (0.1.4) - SwiftProtobuf (1.20.3) @@ -463,9 +459,7 @@ DEPENDENCIES: - React-logger (from `../node_modules/react-native/ReactCommon/logger`) - react-native-blob-util (from `../node_modules/react-native-blob-util`) - 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-randombytes (from `../node_modules/react-native-randombytes`) - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`) - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) @@ -571,12 +565,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native-blob-util" 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-randombytes: - :path: "../node_modules/react-native-randombytes" react-native-safe-area-context: :path: "../node_modules/react-native-safe-area-context" React-perflogger: @@ -623,10 +613,10 @@ SPEC CHECKSUMS: EXConstants: f348da07e21b23d2b085e270d7b74f282df1a7d9 EXFileSystem: 844e86ca9b5375486ecc4ef06d3838d5597d895d EXFont: 6ea3800df746be7233208d80fe379b8ed74f4272 - EXImageLoader: 34b214f9387e98f3c73989f15d8d5b399c9ab3f7 - Expo: b7d2843b0a0027d0ce76121a63085764355a16ed - ExpoDocumentPicker: 5cb7389ff935b4addefdd466a606de51a512e922 - ExpoImagePicker: c58fdf28be551681a8edc550bcec76c397a8dfcd + EXImageLoader: 03063370bc06ea1825713d3f55fe0455f7c88d04 + Expo: 0d9f112757acc6bf32103eabccf91267780bd580 + ExpoDocumentPicker: d3b6b0ed2dbbc2f05158e0294dd3f4673f386e5f + ExpoImagePicker: 9e5c745cb3e56ee00e1cfe5d6af59caab66ecf1a ExpoKeepAwake: 69f5f627670d62318410392d03e0b5db0f85759a ExpoModulesCore: 653958063a301098b541ae4dfed1ac0b98db607b EXSplashScreen: 0e0a9ba0cf7553094e93213099bd7b42e6e237e9 @@ -656,11 +646,9 @@ SPEC CHECKSUMS: React-jsiexecutor: 747911ab5921641b4ed7e4900065896597142125 React-jsinspector: c712f9e3bb9ba4122d6b82b4f906448b8a281580 React-logger: 342f358b8decfbf8f272367f4eacf4b6154061be - react-native-blob-util: 2b6627b288e3bd9874704ea9a153f0a179e4f3f5 + react-native-blob-util: 30a6c9fd067aadf9177e61a998f2c7efb670598d react-native-encrypted-storage: db300a3f2f0aba1e818417c1c0a6be549038deb7 - react-native-get-random-values: a6ea6a8a65dc93e96e24a11105b1a9c8cfe1d72a - react-native-mmkv: 7da5e18e55c04a9af9a7e0ab9792a1e8d33765a1 - react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846 + react-native-mmkv: e97c0c79403fb94577e5d902ab1ebd42b0715b43 react-native-safe-area-context: 39c2d8be3328df5d437ac1700f4f3a4f75716acc React-perflogger: d21f182895de9d1b077f8a3cd00011095c8c9100 React-RCTActionSheet: 0151f83ef92d2a7139bba7dfdbc8066632a6d47b @@ -676,7 +664,7 @@ SPEC CHECKSUMS: React-runtimeexecutor: 7c51ae9d4b3e9608a2366e39ccaa606aa551b9ed ReactCommon: 85c98ab0a509e70bf5ee5d9715cf68dbf495b84c RNScreens: 218801c16a2782546d30bd2026bb625c0302d70f - RNSVG: 53c661b76829783cdaf9b7a57258f3d3b4c28315 + RNSVG: d00c8f91c3cbf6d476451313a18f04d220d4f396 secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634 SwiftProtobuf: b02b5075dcf60c9f5f403000b3b0c202a11b6ae1 web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959 diff --git a/example/package-lock.json b/example/package-lock.json index 5e4042351..3e2baaf2a 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -24,9 +24,7 @@ "react-native-blob-util": "^0.19.0", "react-native-crypto": "^2.2.0", "react-native-encrypted-storage": "^4.0.3", - "react-native-get-random-values": "^1.8.0", "react-native-mmkv": "^2.8.0", - "react-native-randombytes": "^3.6.1", "react-native-safe-area-context": "4.5.0", "react-native-screens": "~3.20.0", "react-native-svg": "^13.9.0", @@ -9087,10 +9085,6 @@ "version": "1.4.4", "license": "MIT" }, - "node_modules/fast-base64-decode": { - "version": "1.0.0", - "license": "MIT" - }, "node_modules/fast-deep-equal": { "version": "3.1.3", "license": "MIT" @@ -13833,16 +13827,6 @@ "react-native": "*" } }, - "node_modules/react-native-get-random-values": { - "version": "1.10.0", - "license": "MIT", - "dependencies": { - "fast-base64-decode": "^1.0.0" - }, - "peerDependencies": { - "react-native": ">=0.56" - } - }, "node_modules/react-native-gradle-plugin": { "version": "0.71.19", "license": "MIT" @@ -13857,7 +13841,9 @@ }, "node_modules/react-native-randombytes": { "version": "3.6.1", - "license": "ISC", + "resolved": "https://registry.npmjs.org/react-native-randombytes/-/react-native-randombytes-3.6.1.tgz", + "integrity": "sha512-qxkwMbOZ0Hff1V7VqpaWrR6ItkA+oF6bnI79Qp9F3Tk8WBsdKDi6m1mi3dEdFWePoRLrhJ2L03rU0yabst1tVw==", + "peer": true, "dependencies": { "buffer": "^4.9.1", "sjcl": "^1.0.3" @@ -14727,6 +14713,7 @@ "node_modules/sjcl": { "version": "1.0.8", "license": "(BSD-2-Clause OR GPL-2.0-only)", + "peer": true, "engines": { "node": "*" } diff --git a/example/package.json b/example/package.json index a2a093fbb..25317966d 100644 --- a/example/package.json +++ b/example/package.json @@ -24,9 +24,7 @@ "react-native-blob-util": "^0.19.0", "react-native-crypto": "^2.2.0", "react-native-encrypted-storage": "^4.0.3", - "react-native-get-random-values": "^1.8.0", "react-native-mmkv": "^2.8.0", - "react-native-randombytes": "^3.6.1", "react-native-safe-area-context": "4.5.0", "react-native-screens": "~3.20.0", "react-native-svg": "^13.9.0", diff --git a/example/src/tests.ts b/example/src/tests.ts index 3736f8fb3..50d9180cc 100644 --- a/example/src/tests.ts +++ b/example/src/tests.ts @@ -1,5 +1,4 @@ import { content } from '@xmtp/proto' -import { randomBytes } from 'crypto' import ReactNativeBlobUtil from 'react-native-blob-util' import { @@ -152,7 +151,7 @@ test('canMessage', async () => { test('createFromKeyBundle throws error for non string value', async () => { try { - const bytes = randomBytes(32) + const bytes = [1, 2, 3] await Client.createFromKeyBundle(JSON.stringify(bytes), { env: 'local', }) @@ -231,8 +230,23 @@ test('can list batch messages', async () => { throw Error('No message') } - if (messages[0].contentTypeId !== 'org/reaction:1.0') { - throw Error('Unexpected message content ' + messages[0].content) + const getCircularReplacer = () => { + const seen = new WeakSet() + return (key, value) => { + if (typeof value === 'object' && value !== null) { + if (seen.has(value)) { + return + } + seen.add(value) + } + return value + } + } + + if (messages[0].contentTypeId !== 'xmtp.org/reaction:1.0') { + throw Error( + 'Unexpected message content ' + JSON.stringify(messages[0].contentTypeId) + ) } if (messages[0].fallback !== 'Reacted “💖” to an earlier message') { @@ -484,7 +498,7 @@ test('remote attachments should work', async () => { } const message = messages[0] - if (message.contentTypeId !== 'org/remoteStaticAttachment:1.0') { + if (message.contentTypeId !== 'xmtp.org/remoteStaticAttachment:1.0') { throw new Error('Expected correctly formatted typeId') } if (!message.content().remoteAttachment) { @@ -547,8 +561,8 @@ test('can send read receipts', async () => { throw Error('No message') } - if (bobMessages[0].contentTypeId !== 'org/readReceipt:1.0') { - throw Error('Unexpected message content ' + bobMessages[0].content) + if (bobMessages[0].contentTypeId !== 'xmtp.org/readReceipt:1.0') { + throw Error('Unexpected message content ' + bobMessages[0].contentTypeId) } if (bobMessages[0].fallback) {