crypto: Don't require the account loading method to borrow self mutably.
parent
947fa08dae
commit
2437a92998
|
@ -53,7 +53,7 @@ impl CryptoStore for MemoryStore {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn save_account(&mut self, _: Account) -> Result<()> {
|
async fn save_account(&self, _: Account) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ mod test {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_session_store() {
|
async fn test_session_store() {
|
||||||
let (account, session) = get_account_and_session().await;
|
let (account, session) = get_account_and_session().await;
|
||||||
let mut store = MemoryStore::new();
|
let store = MemoryStore::new();
|
||||||
|
|
||||||
assert!(store.load_account().await.unwrap().is_none());
|
assert!(store.load_account().await.unwrap().is_none());
|
||||||
store.save_account(account).await.unwrap();
|
store.save_account(account).await.unwrap();
|
||||||
|
|
|
@ -102,7 +102,7 @@ pub trait CryptoStore: Debug {
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `account` - The account that should be stored.
|
/// * `account` - The account that should be stored.
|
||||||
async fn save_account(&mut self, account: Account) -> Result<()>;
|
async fn save_account(&self, account: Account) -> Result<()>;
|
||||||
|
|
||||||
/// Save the given sessions in the store.
|
/// Save the given sessions in the store.
|
||||||
///
|
///
|
||||||
|
|
|
@ -704,7 +704,7 @@ impl CryptoStore for SqliteStore {
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn save_account(&mut self, account: Account) -> Result<()> {
|
async fn save_account(&self, account: Account) -> Result<()> {
|
||||||
let pickle = account.pickle(self.get_pickle_mode()).await;
|
let pickle = account.pickle(self.get_pickle_mode()).await;
|
||||||
let mut connection = self.connection.lock().await;
|
let mut connection = self.connection.lock().await;
|
||||||
|
|
||||||
|
@ -932,7 +932,7 @@ mod test {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_loaded_store() -> (Account, SqliteStore, tempfile::TempDir) {
|
async fn get_loaded_store() -> (Account, SqliteStore, tempfile::TempDir) {
|
||||||
let (mut store, dir) = get_store(None).await;
|
let (store, dir) = get_store(None).await;
|
||||||
let account = get_account();
|
let account = get_account();
|
||||||
store
|
store
|
||||||
.save_account(account.clone())
|
.save_account(account.clone())
|
||||||
|
@ -1000,7 +1000,7 @@ mod test {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn save_account() {
|
async fn save_account() {
|
||||||
let (mut store, _dir) = get_store(None).await;
|
let (store, _dir) = get_store(None).await;
|
||||||
assert!(store.load_account().await.unwrap().is_none());
|
assert!(store.load_account().await.unwrap().is_none());
|
||||||
let account = get_account();
|
let account = get_account();
|
||||||
|
|
||||||
|
@ -1012,7 +1012,7 @@ mod test {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn load_account() {
|
async fn load_account() {
|
||||||
let (mut store, _dir) = get_store(None).await;
|
let (store, _dir) = get_store(None).await;
|
||||||
let account = get_account();
|
let account = get_account();
|
||||||
|
|
||||||
store
|
store
|
||||||
|
@ -1028,7 +1028,7 @@ mod test {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn load_account_with_passphrase() {
|
async fn load_account_with_passphrase() {
|
||||||
let (mut store, _dir) = get_store(Some("secret_passphrase")).await;
|
let (store, _dir) = get_store(Some("secret_passphrase")).await;
|
||||||
let account = get_account();
|
let account = get_account();
|
||||||
|
|
||||||
store
|
store
|
||||||
|
@ -1044,7 +1044,7 @@ mod test {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn save_and_share_account() {
|
async fn save_and_share_account() {
|
||||||
let (mut store, _dir) = get_store(None).await;
|
let (store, _dir) = get_store(None).await;
|
||||||
let account = get_account();
|
let account = get_account();
|
||||||
|
|
||||||
store
|
store
|
||||||
|
@ -1067,7 +1067,7 @@ mod test {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn save_session() {
|
async fn save_session() {
|
||||||
let (mut store, _dir) = get_store(None).await;
|
let (store, _dir) = get_store(None).await;
|
||||||
let (account, session) = get_account_and_session().await;
|
let (account, session) = get_account_and_session().await;
|
||||||
|
|
||||||
assert!(store.save_sessions(&[session.clone()]).await.is_err());
|
assert!(store.save_sessions(&[session.clone()]).await.is_err());
|
||||||
|
@ -1082,7 +1082,7 @@ mod test {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn load_sessions() {
|
async fn load_sessions() {
|
||||||
let (mut store, _dir) = get_store(None).await;
|
let (store, _dir) = get_store(None).await;
|
||||||
let (account, session) = get_account_and_session().await;
|
let (account, session) = get_account_and_session().await;
|
||||||
store
|
store
|
||||||
.save_account(account.clone())
|
.save_account(account.clone())
|
||||||
|
@ -1101,7 +1101,7 @@ mod test {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn add_and_save_session() {
|
async fn add_and_save_session() {
|
||||||
let (mut store, dir) = get_store(None).await;
|
let (store, dir) = get_store(None).await;
|
||||||
let (account, session) = get_account_and_session().await;
|
let (account, session) = get_account_and_session().await;
|
||||||
let sender_key = session.sender_key.to_owned();
|
let sender_key = session.sender_key.to_owned();
|
||||||
let session_id = session.session_id().to_owned();
|
let session_id = session.session_id().to_owned();
|
||||||
|
|
Loading…
Reference in New Issue