From e7b32ea155ac4ae81a3caeb31cc65836073f7f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Wed, 11 Mar 2020 10:09:00 +0100 Subject: [PATCH] crypto: Fix the one-time-key count updating. --- src/crypto/machine.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/crypto/machine.rs b/src/crypto/machine.rs index b2ea9fc6..5419425a 100644 --- a/src/crypto/machine.rs +++ b/src/crypto/machine.rs @@ -96,10 +96,8 @@ impl OlmMachine { .one_time_key_counts .get(&keys::KeyAlgorithm::SignedCurve25519); - if let Some(c) = one_time_key_count { - let count: u64 = (*c).into(); - self.uploaded_signed_key_count = Some(count); - } + let count: u64 = one_time_key_count.map_or(0, |c| (*c).into()); + self.uploaded_signed_key_count = Some(count); self.account.mark_keys_as_published(); // TODO save the account here. @@ -369,7 +367,7 @@ mod test { assert!(machine.should_upload_keys()); machine.receive_keys_upload_response(&response).await; - assert!(!machine.should_upload_keys()); + assert!(machine.should_upload_keys()); response.one_time_key_counts.insert( keys::KeyAlgorithm::SignedCurve25519,