Skip to content

Commit

Permalink
remove setting the db directory
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed May 29, 2024
1 parent 8f8c06d commit fb90732
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 70 deletions.
12 changes: 2 additions & 10 deletions Sources/XMTPiOS/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,14 @@ public struct ClientOptions {
preEnableIdentityCallback: PreEventCallback? = nil,
preCreateIdentityCallback: PreEventCallback? = nil,
mlsAlpha: Bool = false,
mlsEncryptionKey: Data? = nil,
mlsDbDirectory: String? = nil
mlsEncryptionKey: Data? = nil
) {
self.api = api
self.codecs = codecs
self.preEnableIdentityCallback = preEnableIdentityCallback
self.preCreateIdentityCallback = preCreateIdentityCallback
self.mlsAlpha = mlsAlpha
self.mlsEncryptionKey = mlsEncryptionKey
self.mlsDbDirectory = mlsDbDirectory
}
}

Expand Down Expand Up @@ -148,13 +146,7 @@ public final class Client {
}

let alias = "xmtp-\(options?.api.env.rawValue ?? "")-\(inboxId ?? address).db3"
let dbURL: String
if let mlsDbDirectory = options?.mlsDbDirectory {
let mlsDbDirectoryURL = URL(fileURLWithPath: mlsDbDirectory)
dbURL = mlsDbDirectoryURL.appendingPathComponent(alias).path
} else {
dbURL = URL.documentsDirectory.appendingPathComponent(alias).path
}
let dbURL = URL.documentsDirectory.appendingPathComponent(alias).path

let encryptionKey = options?.mlsEncryptionKey

Expand Down
60 changes: 0 additions & 60 deletions Tests/XMTPTests/ClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,66 +93,6 @@ class ClientTests: XCTestCase {
}
}

func testPassingMLSEncryptionKeyAndDatabasePath() async throws {
let bo = try PrivateKey.generate()
let key = try Crypto.secureRandomBytes(count: 32)
let documentsURL = try
FileManager.default.url(
for: .documentDirectory,
in: .userDomainMask,
appropriateFor: nil,
create: false
)

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

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

XCTAssertEqual(client.address, bundleClient.address)
XCTAssert(!client.installationID.isEmpty)

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

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

func testCanDeleteDatabase() async throws {
let bo = try PrivateKey.generate()
let alix = try PrivateKey.generate()
Expand Down

0 comments on commit fb90732

Please sign in to comment.