From 87d0102663f8ece270778c0a9c193ced14c7a260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 13 Aug 2020 15:54:42 +0200 Subject: [PATCH] crypto: Test the Olm machine with the default store. --- matrix_sdk_crypto/src/machine.rs | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index 028463ad..56aa70ef 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -1389,6 +1389,7 @@ mod test { use http::Response; use serde_json::json; + use tempfile::tempdir; use crate::{ machine::{OlmMachine, OneTimeKeys}, @@ -1943,4 +1944,42 @@ mod test { _ => panic!("Decrypted room event has the wrong type"), } } + + #[tokio::test] + async fn test_machine_with_default_store() { + let tmpdir = tempdir().unwrap(); + + let machine = OlmMachine::new_with_default_store( + &user_id(), + &alice_device_id(), + tmpdir.as_ref(), + "test", + ) + .await + .unwrap(); + + let user_id = machine.user_id().to_owned(); + let device_id = machine.device_id().to_owned(); + let ed25519_key = machine.identity_keys().ed25519().to_owned(); + + machine + .receive_keys_upload_response(&keys_upload_response()) + .await + .unwrap(); + + drop(machine); + + let machine = OlmMachine::new_with_default_store( + &user_id, + &alice_device_id(), + tmpdir.as_ref(), + "test", + ) + .await + .unwrap(); + + assert_eq!(&user_id, machine.user_id()); + assert_eq!(&*device_id, machine.device_id()); + assert_eq!(ed25519_key, machine.identity_keys().ed25519()); + } }