diff --git a/crates/matrix-sdk-indexeddb/Cargo.toml b/crates/matrix-sdk-indexeddb/Cargo.toml index 0e5fb1921..80b9e7eae 100644 --- a/crates/matrix-sdk-indexeddb/Cargo.toml +++ b/crates/matrix-sdk-indexeddb/Cargo.toml @@ -38,3 +38,4 @@ matrix-sdk-base = { path = "../matrix-sdk-base", features = ["testing"] } matrix-sdk-crypto = { path = "../matrix-sdk-crypto", features = ["testing"] } matrix-sdk-test = { path = "../matrix-sdk-test" } wasm-bindgen-test = "0.3.24" +uuid = "0.8" \ No newline at end of file diff --git a/crates/matrix-sdk-indexeddb/src/state_store.rs b/crates/matrix-sdk-indexeddb/src/state_store.rs index 62c855625..50301acda 100644 --- a/crates/matrix-sdk-indexeddb/src/state_store.rs +++ b/crates/matrix-sdk-indexeddb/src/state_store.rs @@ -199,17 +199,11 @@ impl IndexeddbStore { Ok(IndexeddbStore::open_helper("state".to_owned(), None).await?) } - #[allow(dead_code)] - pub(crate) async fn open_encrypted() -> StoreResult { - let key = StoreCipher::new().map_err::(|e| e.into())?; - Ok(IndexeddbStore::open_helper("state_encrypted".to_owned(), Some(key)).await?) - } - pub async fn open_with_passphrase(name: String, passphrase: &str) -> StoreResult { Ok(Self::inner_open_with_passphrase(name, passphrase).await?) } - async fn inner_open_with_passphrase(name: String, passphrase: &str) -> Result { + pub(crate) async fn inner_open_with_passphrase(name: String, passphrase: &str) -> Result { let name = format!("{:0}::matrix-sdk-state", name); let mut db_req: OpenDbRequest = IdbDatabase::open_u32(&name, 1)?; @@ -1289,10 +1283,13 @@ mod encrypted_tests { use matrix_sdk_base::statestore_integration_tests; - use super::{IndexeddbStore, Result}; + use super::{IndexeddbStore, Result, StoreCipher}; + use uuid::Uuid; async fn get_store() -> Result { - Ok(IndexeddbStore::open_encrypted().await?) + let db_name = format!("test-state-encrypted-{}", Uuid::new_v4().to_hyphenated().to_string()); + let key = StoreCipher::new()?; + Ok(IndexeddbStore::open_helper(db_name, Some(key)).await?) } statestore_integration_tests! { integration }