Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix passing DB Path #260

Merged
merged 4 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/XMTPiOS/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,16 @@ public struct ClientOptions {
preEnableIdentityCallback: PreEventCallback? = nil,
preCreateIdentityCallback: PreEventCallback? = nil,
mlsAlpha: Bool = false,
mlsEncryptionKey: Data? = nil
mlsEncryptionKey: Data? = nil,
mlsDbPath: String? = nil
) {
self.api = api
self.codecs = codecs
self.preEnableIdentityCallback = preEnableIdentityCallback
self.preCreateIdentityCallback = preCreateIdentityCallback
self.mlsAlpha = mlsAlpha
self.mlsEncryptionKey = mlsEncryptionKey
self.mlsDbPath = mlsDbPath
}
}

Expand Down
53 changes: 53 additions & 0 deletions Tests/XMTPTests/ClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,59 @@ class ClientTests: XCTestCase {
XCTAssert(true)
}
}

func testPassingMLSEncryptionKeyAndDatabasePath() async throws {
let bo = try PrivateKey.generate()
let key = try Crypto.secureRandomBytes(count: 32)
let dbPath = URL.documentsDirectory.appendingPathComponent("xmtp-\(bo.walletAddress).db3").path

let client = try await Client.create(
account: bo,
options: .init(
api: .init(env: .local, isSecure: false),
mlsAlpha: true,
mlsEncryptionKey: key,
mlsDbPath: dbPath
)
)

let keys = client.privateKeyBundle
let bundleClient = try await Client.from(
bundle: keys,
options: .init(
api: .init(env: .local, isSecure: false),
mlsAlpha: true,
mlsEncryptionKey: key,
mlsDbPath: dbPath
)
)

XCTAssertEqual(client.address, bundleClient.address)

await assertThrowsAsyncError(
_ = try await Client.from(
bundle: keys,
options: .init(
api: .init(env: .local, isSecure: false),
mlsAlpha: true,
mlsEncryptionKey: nil,
mlsDbPath: dbPath
)
)
)

await assertThrowsAsyncError(
_ = try await Client.from(
bundle: keys,
options: .init(
api: .init(env: .local, isSecure: false),
mlsAlpha: true,
mlsEncryptionKey: key,
mlsDbPath: nil
)
)
)
}

func testCanMessage() async throws {
let fixtures = await fixtures()
Expand Down
2 changes: 1 addition & 1 deletion XMTP.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
#

spec.name = "XMTP"
spec.version = "0.8.10"
spec.version = "0.8.11"
spec.summary = "XMTP SDK Cocoapod"

# This description is used to generate tags and improve search results.
Expand Down
Loading