Skip to content

Commit 27cbc33

Browse files
committed
chore(swift): adjust tests to the new api
1 parent da2aa2d commit 27cbc33

File tree

2 files changed

+33
-18
lines changed

2 files changed

+33
-18
lines changed

crypto-ffi/bindings/swift/WireCoreCrypto/WireCoreCryptoTests/WireCoreCryptoTests.swift

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ final class WireCoreCryptoTests: XCTestCase {
497497
XCTAssertTrue(resultAfter)
498498
}
499499

500+
// swiftlint:disable:next function_body_length
500501
func testUpdateKeyingMaterialShouldProcessTheCommitMessage() async throws {
501502
let conversationId = ConversationId(bytes: Data("conversation1".utf8))
502503
let ciphersuite = try ciphersuiteFromU16(discriminant: 2)
@@ -520,11 +521,18 @@ final class WireCoreCryptoTests: XCTestCase {
520521
)
521522
}
522523
let aliceKp = try await alice.transaction {
523-
try await $0.clientKeypackages(
524+
let credential = try await $0.findCredentials(
525+
clientId: nil,
526+
publicKey: nil,
524527
ciphersuite: ciphersuite,
525528
credentialType: .basic,
526-
amountRequested: 1
529+
earliestValidity: nil
527530
).first!
531+
532+
try await $0.generateKeypackage(
533+
credentialRef: credential,
534+
lifetime: nil
535+
)
528536
}
529537
try await bob.transaction {
530538
_ = try await $0.addClientsToConversation(
@@ -576,11 +584,18 @@ final class WireCoreCryptoTests: XCTestCase {
576584
}
577585

578586
let aliceKp = try await alice.transaction {
579-
try await $0.clientKeypackages(
587+
let credential = try await $0.findCredentials(
588+
clientId: nil,
589+
publicKey: nil,
580590
ciphersuite: ciphersuite,
581591
credentialType: .basic,
582-
amountRequested: 1
592+
earliestValidity: nil
583593
).first!
594+
595+
try await $0.generateKeypackage(
596+
credentialRef: credential,
597+
lifetime: nil
598+
)
584599
}
585600
try await bob.transaction {
586601
_ = try await $0.addClientsToConversation(

interop/src/clients/InteropClient/InteropClient/InteropClientApp.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,26 +124,26 @@ struct InteropClientApp: App {
124124
case .getKeyPackage(let ciphersuite):
125125
guard let coreCrypto else { throw InteropError.notInitialised }
126126

127-
let keyPackage = try await coreCrypto.transaction {
128-
try await $0.clientKeypackages(
129-
ciphersuite: ciphersuiteFromU16(discriminant: ciphersuite),
130-
credentialType: .basic,
131-
amountRequested: 1)
132-
}
127+
let credential = try await $0.findCredentials(
128+
clientId: nil,
129+
publicKey: nil,
130+
ciphersuite: ciphersuiteFromU16(discriminant: ciphersuite),
131+
credentialType: .basic,
132+
earliestValidity: nil
133+
).first!
134+
135+
let keyPackage = try await $0.generateKeypackage(
136+
credentialRef: credential,
137+
lifetime: nil
138+
)
133139

134-
if let encodedKeyPackage = keyPackage.first.map({
135-
$0.copyBytes().base64EncodedString()
136-
}) {
137-
return encodedKeyPackage
138-
} else {
139-
throw InteropError.encodingError
140-
}
140+
return try keyPackage.serialize().base64EncodedString()
141141

142142
case .addClient(let conversationId, let ciphersuite, let keyPackage):
143143
guard let coreCrypto else { throw InteropError.notInitialised }
144144
let conversationId = ConversationId(bytes: conversationId)
145145
let ciphersuite = try ciphersuiteFromU16(discriminant: ciphersuite)
146-
let keyPackage = KeyPackage(bytes: keyPackage)
146+
let keyPackage = try Keypackage(bytes: keyPackage)
147147

148148
try await coreCrypto.transaction { context in
149149
if try await context.conversationExists(

0 commit comments

Comments
 (0)