Skip to content
Open
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
2 changes: 1 addition & 1 deletion Sources/Encryption/SenderKeyRecord.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class SenderKeyRecord {
func state(for id: UInt32) -> SenderKeyState? {
for item in states {
if item.keyId == id {
return state
return item
}
}
return nil
Expand Down
12 changes: 12 additions & 0 deletions Tests/SenderKeyRecordTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ class SenderKeyRecordTests: XCTestCase {
chainKey: senderKey2,
signatureKeyPair: senderSigningKey2)

guard let state = record.state(for: stateId1) else {
XCTFail("\(stateId1) missed")
return
}
XCTAssertEqual(state.keyId, stateId1)

guard let state = record.state(for: stateId2) else {
XCTFail("\(stateId2) missed")
return
}
XCTAssertEqual(state.keyId, stateId2)

guard let serialized = try? record.protoData() else {
XCTFail("Could not serialize SenderKeyRecord")
return
Expand Down