diff --git a/crates/matrix-sdk-crypto/src/dehydrated_devices.rs b/crates/matrix-sdk-crypto/src/dehydrated_devices.rs index c1ced5201..f10a180fc 100644 --- a/crates/matrix-sdk-crypto/src/dehydrated_devices.rs +++ b/crates/matrix-sdk-crypto/src/dehydrated_devices.rs @@ -389,8 +389,8 @@ mod tests { use crate::{ machine::{ - test_helpers::get_prepared_machine_test_helper, - tests::{create_session, to_device_requests_to_content}, + test_helpers::{create_session, get_prepared_machine_test_helper}, + tests::to_device_requests_to_content, }, olm::OutboundGroupSession, types::{events::ToDeviceEvent, DeviceKeys as DeviceKeysType}, diff --git a/crates/matrix-sdk-crypto/src/machine/mod.rs b/crates/matrix-sdk-crypto/src/machine/mod.rs index 643ee5056..4255ca328 100644 --- a/crates/matrix-sdk-crypto/src/machine/mod.rs +++ b/crates/matrix-sdk-crypto/src/machine/mod.rs @@ -2408,7 +2408,6 @@ pub(crate) mod tests { api::{ client::{ keys::{ - claim_keys, get_keys::{self, v3::Response as KeyQueryResponse}, upload_keys, }, @@ -2418,7 +2417,6 @@ pub(crate) mod tests { IncomingResponse, }, device_id, - encryption::OneTimeKey, events::{ dummy::ToDeviceDummyEventContent, key::verification::VerificationMethod, @@ -2432,7 +2430,7 @@ pub(crate) mod tests { serde::Raw, to_device::DeviceIdOrAllDevices, uint, user_id, DeviceId, DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch, - OwnedDeviceKeyId, RoomId, SecondsSinceUnixEpoch, TransactionId, UserId, + RoomId, SecondsSinceUnixEpoch, TransactionId, UserId, }; use serde_json::{json, value::to_raw_value}; use vodozemac::{ @@ -2445,7 +2443,7 @@ pub(crate) mod tests { error::{EventError, SetRoomSettingsError}, machine::{ test_helpers::{ - get_machine_after_query_test_helper, get_machine_pair, + create_session, get_machine_after_query_test_helper, get_machine_pair, get_machine_pair_with_session, get_machine_pair_with_setup_sessions_test_helper, get_prepared_machine_test_helper, }, @@ -2782,22 +2780,6 @@ pub(crate) mod tests { assert!(user_sessions.contains_key(alice_device)); } - pub async fn create_session( - machine: &OlmMachine, - user_id: &UserId, - device_id: &DeviceId, - key_id: OwnedDeviceKeyId, - one_time_key: Raw, - ) { - let one_time_keys = BTreeMap::from([( - user_id.to_owned(), - BTreeMap::from([(device_id.to_owned(), BTreeMap::from([(key_id, one_time_key)]))]), - )]); - - let response = claim_keys::v3::Response::new(one_time_keys); - machine.inner.session_manager.create_sessions(&response).await.unwrap(); - } - #[async_test] async fn test_session_creation() { let (alice_machine, bob_machine, mut one_time_keys) = diff --git a/crates/matrix-sdk-crypto/src/machine/test_helpers.rs b/crates/matrix-sdk-crypto/src/machine/test_helpers.rs index 3fb69bd5d..fa4a0e398 100644 --- a/crates/matrix-sdk-crypto/src/machine/test_helpers.rs +++ b/crates/matrix-sdk-crypto/src/machine/test_helpers.rs @@ -169,3 +169,20 @@ pub async fn get_machine_pair_with_setup_sessions_test_helper( (alice, bob) } + +/// Create an Olm session from the given machine to the given device +pub async fn create_session( + machine: &OlmMachine, + user_id: &UserId, + device_id: &DeviceId, + key_id: OwnedDeviceKeyId, + one_time_key: Raw, +) { + let one_time_keys = BTreeMap::from([( + user_id.to_owned(), + BTreeMap::from([(device_id.to_owned(), BTreeMap::from([(key_id, one_time_key)]))]), + )]); + + let response = claim_keys::v3::Response::new(one_time_keys); + machine.inner.session_manager.create_sessions(&response).await.unwrap(); +}