Skip to content

Commit fb05227

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

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
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+
return 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+
return 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: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,25 +125,27 @@ struct InteropClientApp: App {
125125
guard let coreCrypto else { throw InteropError.notInitialised }
126126

127127
let keyPackage = try await coreCrypto.transaction {
128-
try await $0.clientKeypackages(
128+
let credential = try await $0.findCredentials(
129+
clientId: nil,
130+
publicKey: nil,
129131
ciphersuite: ciphersuiteFromU16(discriminant: ciphersuite),
130132
credentialType: .basic,
131-
amountRequested: 1)
132-
}
133+
earliestValidity: nil
134+
).first!
133135

134-
if let encodedKeyPackage = keyPackage.first.map({
135-
$0.copyBytes().base64EncodedString()
136-
}) {
137-
return encodedKeyPackage
138-
} else {
139-
throw InteropError.encodingError
136+
try await $0.generateKeypackage(
137+
credentialRef: credential,
138+
lifetime: nil
139+
)
140140
}
141141

142+
return try keyPackage.serialize().base64EncodedString()
143+
142144
case .addClient(let conversationId, let ciphersuite, let keyPackage):
143145
guard let coreCrypto else { throw InteropError.notInitialised }
144146
let conversationId = ConversationId(bytes: conversationId)
145147
let ciphersuite = try ciphersuiteFromU16(discriminant: ciphersuite)
146-
let keyPackage = KeyPackage(bytes: keyPackage)
148+
let keyPackage = try Keypackage(bytes: keyPackage)
147149

148150
try await coreCrypto.transaction { context in
149151
if try await context.conversationExists(

0 commit comments

Comments
 (0)