Skip to content

Commit

Permalink
fix: get iOS test passing
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Nov 1, 2024
1 parent 793c523 commit 4431d29
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ class XMTPModule : Module() {
"sign",
"authed",
"authedV3",
"bundleAuthed",
"preCreateIdentityCallback",
"preEnableIdentityCallback",
"preAuthenticateToInboxCallback",
Expand Down Expand Up @@ -431,7 +432,7 @@ class XMTPModule : Module() {
clients[client.inboxId] = client
ContentJson.Companion
signer = null
sendEvent("authed", ClientWrapper.encodeToObj(client))
sendEvent("bundleAuthed", ClientWrapper.encodeToObj(client))
} catch (e: Exception) {
throw XMTPException("Failed to create client: $e")
}
Expand Down
14 changes: 7 additions & 7 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ PODS:
- hermes-engine/Pre-built (= 0.71.14)
- hermes-engine/Pre-built (0.71.14)
- libevent (2.1.12)
- LibXMTP (0.5.10)
- LibXMTP (0.6.0)
- Logging (1.0.0)
- MessagePacker (0.4.7)
- MMKV (2.0.0):
Expand Down Expand Up @@ -449,16 +449,16 @@ PODS:
- GenericJSON (~> 2.0)
- Logging (~> 1.0.0)
- secp256k1.swift (~> 0.1)
- XMTP (0.16.0):
- XMTP (0.16.1):
- Connect-Swift (= 0.12.0)
- GzipSwift
- LibXMTP (= 0.5.10)
- LibXMTP (= 0.6.0)
- web3.swift
- XMTPReactNative (0.1.0):
- ExpoModulesCore
- MessagePacker
- secp256k1.swift
- XMTP (= 0.16.0)
- XMTP (= 0.16.1)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -711,7 +711,7 @@ SPEC CHECKSUMS:
GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa
hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
LibXMTP: 3b64b0b1e4157ff73c37cde60fe943f89e6f8693
LibXMTP: 059c6d51b2c59419941ecff600aa586bbe083673
Logging: 9ef4ecb546ad3169398d5a723bc9bea1c46bef26
MessagePacker: ab2fe250e86ea7aedd1a9ee47a37083edd41fd02
MMKV: f7d1d5945c8765f97f39c3d121f353d46735d801
Expand Down Expand Up @@ -763,8 +763,8 @@ SPEC CHECKSUMS:
secp256k1.swift: a7e7a214f6db6ce5db32cc6b2b45e5c4dd633634
SwiftProtobuf: 407a385e97fd206c4fbe880cc84123989167e0d1
web3.swift: 2263d1e12e121b2c42ffb63a5a7beb1acaf33959
XMTP: 18d555dbf5afd3dcafa11b108042f9673da3c6b9
XMTPReactNative: cd8be3d8547d116005f3d0f4f207f19c7b34d035
XMTP: b2c2bcb0ddd6fbdb4820cac7be8a694c0f797425
XMTPReactNative: 0b3b70a875bcb3defc24f051f69c35b257037c08
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9

PODFILE CHECKSUM: 0e6fe50018f34e575d38dc6a1fdf1f99c9596cdd
Expand Down
46 changes: 18 additions & 28 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ test('can make a MLS V3 client', async () => {
return true
})

test('can create from key bundle with signer', async () => {
const keyBytes = new Uint8Array([
test('can revoke all other installations', async () => {
const keyBytes = 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,
])
Expand All @@ -75,7 +75,7 @@ test('can create from key bundle with signer', async () => {
const keyBundle = await alix2.exportKeyBundle()

// create from keybundle a v3 client
const alix3 = await Client.createFromKeyBundle(
const alixKeyBundle = await Client.createFromKeyBundle(
keyBundle,
{
env: 'local',
Expand All @@ -86,33 +86,23 @@ test('can create from key bundle with signer', async () => {
alixWallet
)

const inboxState = await alix3.inboxState(true)
const inboxState = await alixKeyBundle.inboxState(true)
assert(
inboxState.installations.length === 2,
`installations length should be 2 but was ${inboxState.installations.length}`
)

return true
})

test('can revoke all other installations', async () => {
const keyBytes = 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 alixWallet = Wallet.createRandom()

const alix = await Client.create(alixWallet, {
const alix3 = await Client.create(alixWallet, {
env: 'local',
appVersion: 'Testing/0.0.0',
enableV3: true,
dbEncryptionKey: keyBytes,
})

const keyBundle = await alix.exportKeyBundle()
const keyBundle2 = await alix3.exportKeyBundle()

await Client.createFromKeyBundle(
keyBundle,
const alixKeyBundle2 = await Client.createFromKeyBundle(

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

View workflow job for this annotation

GitHub Actions / lint

'alixKeyBundle2' is assigned a value but never used
keyBundle2,
{
env: 'local',
appVersion: 'Testing/0.0.0',
Expand All @@ -122,31 +112,31 @@ test('can revoke all other installations', async () => {
alixWallet
)

await alix.deleteLocalDatabase()
await alix3.deleteLocalDatabase()

const alix2 = await Client.create(alixWallet, {
const alix4 = await Client.create(alixWallet, {
env: 'local',
appVersion: 'Testing/0.0.0',
enableV3: true,
dbEncryptionKey: keyBytes,
})

const inboxState = await alix2.inboxState(true)
const inboxState2 = await alix4.inboxState(true)
assert(
inboxState.installations.length === 2,
`installations length should be 2 but was ${inboxState.installations.length}`
inboxState2.installations.length === 3,
`installations length should be 3 but was ${inboxState2.installations.length}`
)

await alix2.revokeAllOtherInstallations(alixWallet)
await alix4.revokeAllOtherInstallations(alixWallet)

const inboxState2 = await alix2.inboxState(true)
const inboxState3 = await alix4.inboxState(true)
assert(
inboxState2.installations.length === 1,
`installations length should be 1 but was ${inboxState2.installations.length}`
inboxState3.installations.length === 1,
`installations length should be 1 but was ${inboxState3.installations.length}`
)

assert(
inboxState2.installations[0].createdAt !== undefined,
inboxState3.installations[0].createdAt !== undefined,
`installations createdAt should not be undefined`
)
return true
Expand Down
3 changes: 2 additions & 1 deletion ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public class XMTPModule: Module {
"sign",
"authed",
"authedV3",
"bundleAuthed",
"preCreateIdentityCallback",
"preEnableIdentityCallback",
"preAuthenticateToInboxCallback",
Expand Down Expand Up @@ -315,7 +316,7 @@ public class XMTPModule: Module {
let client = try await Client.from(v1Bundle: bundle.v1, options: options, signingKey: signer)
await clientsManager.updateClient(key: client.inboxID, client: client)
self.signer = nil
self.sendEvent("authed", try ClientWrapper.encodeToObj(client))
self.sendEvent("bundleAuthed", try ClientWrapper.encodeToObj(client))
} catch {
print("ERROR! Failed to create client: \(error)")
throw error
Expand Down
2 changes: 1 addition & 1 deletion ios/XMTPReactNative.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ Pod::Spec.new do |s|
s.source_files = "**/*.{h,m,swift}"
s.dependency 'secp256k1.swift'
s.dependency "MessagePacker"
s.dependency "XMTP", "= 0.16.0"
s.dependency "XMTP", "= 0.16.1"
end
2 changes: 1 addition & 1 deletion src/lib/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export class Client<
)

this.authSubscription = XMTPModule.emitter.addListener(
'authed',
'bundleAuthed',
async (message: {
inboxId: string
address: string
Expand Down
1 change: 1 addition & 0 deletions src/lib/types/EventTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export enum EventTypes {
Sign = 'sign',
Authed = 'authed',
AuthedV3 = 'authedV3',
BundleAuthed = 'bundleAuthed',
PreCreateIdentityCallback = 'preCreateIdentityCallback',
PreEnableIdentityCallback = 'preEnableIdentityCallback',
// Conversations Events
Expand Down

0 comments on commit 4431d29

Please sign in to comment.