chore: Upgrade testing crates to Rust Edition 2024

This commit is contained in:
Jonas Platte
2025-07-14 21:28:45 +02:00
committed by Ivan Enderlin
parent 8aa6f97f7c
commit ea076b3d76
36 changed files with 163 additions and 148 deletions
@@ -2,7 +2,7 @@
name = "matrix-sdk-integration-testing"
description = "Internal integration testing for matrix-sdk crate"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false
license = "Apache-2.0"
@@ -10,21 +10,21 @@ use std::{
use anyhow::Result;
use assign::assign;
use matrix_sdk::{
Client, ClientBuilder, Room,
config::{RequestConfig, SyncSettings},
encryption::EncryptionSettings,
ruma::{
RoomId,
api::client::{account::register::v3::Request as RegistrationRequest, uiaa},
time::Instant,
RoomId,
},
sliding_sync::VersionBuilder,
sync::SyncResponse,
timeout::ElapsedError,
Client, ClientBuilder, Room,
};
use once_cell::sync::Lazy;
use rand::Rng as _;
use tempfile::{tempdir, TempDir};
use tempfile::{TempDir, tempdir};
use tokio::{sync::Mutex, time::sleep};
/// This global maintains temp directories alive for the whole lifetime of the
@@ -47,7 +47,7 @@ pub struct TestClientBuilder {
impl TestClientBuilder {
pub fn new(username: impl AsRef<str>) -> Self {
let suffix: u128 = rand::thread_rng().gen();
let suffix: u128 = rand::thread_rng().r#gen();
let randomized_username = format!("{}{}", username.as_ref(), suffix);
Self::with_exact_username(randomized_username)
}
@@ -8,31 +8,30 @@ use assert_matches::assert_matches;
use assert_matches2::assert_let;
use assign::assign;
use matrix_sdk::{
assert_next_eq_with_timeout,
crypto::{format_emojis, SasState},
Client, assert_next_eq_with_timeout,
crypto::{SasState, format_emojis},
encryption::{
BackupDownloadStrategy, EncryptionSettings, LocalTrust,
backups::BackupState,
recovery::{Recovery, RecoveryState},
verification::{
QrVerificationData, QrVerificationState, Verification, VerificationRequestState,
},
BackupDownloadStrategy, EncryptionSettings, LocalTrust,
},
ruma::{
OwnedEventId,
api::client::room::create_room::v3::Request as CreateRoomRequest,
events::{
key::verification::{request::ToDeviceKeyVerificationRequestEvent, VerificationMethod},
GlobalAccountDataEventType, OriginalSyncMessageLikeEvent,
key::verification::{VerificationMethod, request::ToDeviceKeyVerificationRequestEvent},
room::message::{
MessageType, OriginalSyncRoomMessageEvent, RoomMessageEventContent,
SyncRoomMessageEvent,
},
secret_storage::secret::SecretEventContent,
GlobalAccountDataEventType, OriginalSyncMessageLikeEvent,
},
OwnedEventId,
},
timeout::timeout,
Client,
};
use matrix_sdk_ui::{
notification_client::{NotificationClient, NotificationProcessSetup},
@@ -51,8 +50,8 @@ mod shared_history;
// processed twice, meaning incorrect verification states will be found and the
// process will fail, especially with user verification.
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn test_mutual_sas_verification_with_notification_client_ignores_verification_events(
) -> Result<()> {
async fn test_mutual_sas_verification_with_notification_client_ignores_verification_events()
-> Result<()> {
let encryption_settings =
EncryptionSettings { auto_enable_cross_signing: true, ..Default::default() };
let alice = TestClientBuilder::new("alice")
@@ -3,7 +3,7 @@ use std::ops::Deref;
use anyhow::Result;
use assert_matches2::assert_let;
use assign::assign;
use futures::{pin_mut, FutureExt, StreamExt};
use futures::{FutureExt, StreamExt, pin_mut};
use matrix_sdk::{
assert_decrypted_message_eq,
encryption::EncryptionSettings,
@@ -15,7 +15,7 @@ use matrix_sdk::{
use matrix_sdk_common::deserialized_responses::ProcessedToDeviceEvent;
use matrix_sdk_ui::sync_service::SyncService;
use similar_asserts::assert_eq;
use tracing::{info, Instrument};
use tracing::{Instrument, info};
use crate::helpers::{SyncTokenAwareClient, TestClientBuilder};
@@ -1,7 +1,7 @@
use anyhow::{ensure, Result};
use anyhow::{Result, ensure};
use assign::assign;
use matrix_sdk::{
ruma::api::client::room::create_room::v3::Request as CreateRoomRequest, RoomState,
RoomState, ruma::api::client::room::create_room::v3::Request as CreateRoomRequest,
};
use crate::helpers::TestClientBuilder;
@@ -8,22 +8,22 @@ use anyhow::Result;
use assign::assign;
use futures::Future;
use matrix_sdk::{
Client, Room,
encryption::EncryptionSettings,
ruma::{
EventEncryptionAlgorithm, OwnedEventId, OwnedRoomId, RoomId,
api::client::room::create_room::v3::Request as CreateRoomRequest,
events::{
AnyMessageLikeEventContent, AnySyncTimelineEvent, OriginalSyncMessageLikeEvent,
room::{
encrypted::{OriginalSyncRoomEncryptedEvent, RoomEncryptedEventContent},
encryption::RoomEncryptionEventContent,
message::{MessageType, OriginalSyncRoomMessageEvent, RoomMessageEventContent},
},
room_key::ToDeviceRoomKeyEvent,
AnyMessageLikeEventContent, AnySyncTimelineEvent, OriginalSyncMessageLikeEvent,
},
serde::Raw,
EventEncryptionAlgorithm, OwnedEventId, OwnedRoomId, RoomId,
},
Client, Room,
};
use matrix_sdk_ui::{
notification_client::{
@@ -33,7 +33,7 @@ use matrix_sdk_ui::{
};
use serde_json::json;
use tempfile::tempdir;
use tracing::{info, instrument, span, Level};
use tracing::{Level, info, instrument, span};
use crate::helpers::{SyncTokenAwareClient, TestClientBuilder};
@@ -2,15 +2,15 @@ use anyhow::Result;
use assert_matches::assert_matches;
use assign::assign;
use matrix_sdk::{
Client,
config::SyncSettings,
ruma::{
api::client::room::create_room::v3::Request as CreateRoomRequest,
events::{
room::name::{RoomNameEventContent, SyncRoomNameEvent},
AnySyncStateEvent, StateEventType,
room::name::{RoomNameEventContent, SyncRoomNameEvent},
},
},
Client,
};
use crate::helpers::TestClientBuilder;
@@ -3,12 +3,12 @@ use std::{sync::Arc, time::Duration};
use anyhow::Result;
use assign::assign;
use matrix_sdk::{
Client, Room, RoomMemberships, RoomState, StateStoreExt,
event_handler::Ctx,
ruma::{
api::client::room::create_room::v3::Request as CreateRoomRequest,
events::room::member::{MembershipState, StrippedRoomMemberEvent},
},
Client, Room, RoomMemberships, RoomState, StateStoreExt,
};
use matrix_sdk_common::executor::spawn;
use tokio::sync::Notify;
@@ -3,24 +3,24 @@ use std::time::Duration;
use anyhow::Result;
use assert_matches2::{assert_let, assert_matches};
use matrix_sdk::{
RoomState,
room::MessagesOptions,
ruma::{
api::client::room::create_room::v3::Request as CreateRoomRequest,
assign, event_id, events,
events::{
room::message::RoomMessageEventContent, AnyRoomAccountDataEventContent,
AnySyncStateEvent, AnySyncTimelineEvent, EventContent,
AnyRoomAccountDataEventContent, AnySyncStateEvent, AnySyncTimelineEvent, EventContent,
room::message::RoomMessageEventContent,
},
serde::Raw,
uint,
},
test_utils::assert_event_matches_msg,
RoomState,
};
use tokio::{spawn, time::sleep};
use tracing::error;
use crate::helpers::{wait_for_room, TestClientBuilder};
use crate::helpers::{TestClientBuilder, wait_for_room};
#[tokio::test]
async fn test_event_with_context() -> Result<()> {
@@ -21,9 +21,9 @@ use eyeball_im::VectorDiff;
use futures::StreamExt;
use matrix_sdk::{
room_directory_search::RoomDirectorySearch,
ruma::api::client::room::{create_room::v3::Request as CreateRoomRequest, Visibility},
ruma::api::client::room::{Visibility, create_room::v3::Request as CreateRoomRequest},
};
use rand::{thread_rng, Rng};
use rand::{Rng, thread_rng};
use stream_assert::assert_pending;
use tokio::time::sleep;
use tracing::warn;
@@ -19,9 +19,10 @@ use assign::assign;
use matrix_sdk::{
config::SyncSettings,
ruma::{
RoomAliasId,
api::client::{
directory::get_public_rooms_filtered,
room::{create_room::v3::Request as CreateRoomRequest, Visibility},
room::{Visibility, create_room::v3::Request as CreateRoomRequest},
},
directory::Filter,
events::room::{
@@ -32,7 +33,6 @@ use matrix_sdk::{
},
},
serde::Raw,
RoomAliasId,
},
};
use matrix_sdk_base::ruma::events::room::canonical_alias::SyncRoomCanonicalAliasEvent;
@@ -3,21 +3,21 @@
use std::sync::Arc;
use anyhow::{ensure, Result};
use anyhow::{Result, ensure};
use assert_matches::assert_matches;
use assert_matches2::assert_let;
use matrix_sdk::{
RoomState,
config::SyncSettings,
ruma::{
OwnedEventId,
api::client::room::create_room::v3::Request as CreateRoomRequest,
assign,
events::{
room::{member::MembershipState, message::RoomMessageEventContent},
AnyStrippedStateEvent, SyncMessageLikeEvent, TimelineEventType,
room::{member::MembershipState, message::RoomMessageEventContent},
},
OwnedEventId,
},
RoomState,
};
use matrix_sdk_ui::{
notification_client::{
@@ -11,12 +11,14 @@ use anyhow::Result;
use assert_matches::assert_matches;
use assert_matches2::assert_let;
use eyeball_im::VectorDiff;
use futures_util::{pin_mut, StreamExt as _};
use futures_util::{StreamExt as _, pin_mut};
use matrix_sdk::{
Client, Room, RoomInfo, RoomMemberships, RoomState, SlidingSyncList, SlidingSyncMode,
bytes::Bytes,
config::SyncSettings,
room_preview::RoomPreview,
ruma::{
RoomId,
api::client::{
receipt::create_receipt::v3::ReceiptType,
room::create_room::v3::{Request as CreateRoomRequest, RoomPreset},
@@ -24,29 +26,28 @@ use matrix_sdk::{
assign,
directory::PublicRoomsChunkInit,
events::{
AnySyncMessageLikeEvent, InitialStateEvent, Mentions, StateEventType,
receipt::ReceiptThread,
room::{
history_visibility::{HistoryVisibility, RoomHistoryVisibilityEventContent},
join_rules::{JoinRule, RoomJoinRulesEventContent},
message::RoomMessageEventContent,
},
AnySyncMessageLikeEvent, InitialStateEvent, Mentions, StateEventType,
},
mxc_uri, owned_server_name, room_id,
space::SpaceRoomJoinRule,
uint, RoomId,
uint,
},
sliding_sync::VersionBuilder,
test_utils::{logged_in_client_with_server, mocks::MatrixMockServer},
Client, Room, RoomInfo, RoomMemberships, RoomState, SlidingSyncList, SlidingSyncMode,
};
use matrix_sdk_base::ruma::{
api::client::sync::sync_events::v5 as http, owned_room_id, room_alias_id,
};
use matrix_sdk_test::async_test;
use matrix_sdk_ui::{
room_list_service::filters::new_filter_all, sync_service::SyncService, timeline::RoomExt,
RoomListService,
RoomListService, room_list_service::filters::new_filter_all, sync_service::SyncService,
timeline::RoomExt,
};
use once_cell::sync::Lazy;
use rand::Rng as _;
@@ -58,9 +59,9 @@ use tokio::{
time::{sleep, timeout},
};
use tracing::{debug, error, info, trace, warn};
use wiremock::{matchers::AnyMatcher, Mock, MockServer};
use wiremock::{Mock, MockServer, matchers::AnyMatcher};
use crate::helpers::{wait_for_room, TestClientBuilder};
use crate::helpers::{TestClientBuilder, wait_for_room};
#[tokio::test]
async fn test_left_room() -> Result<()> {
@@ -1060,7 +1061,7 @@ async fn test_room_preview() -> Result<()> {
.await?;
// Alice creates a room in which they're alone, to start with.
let suffix: u128 = rand::thread_rng().gen();
let suffix: u128 = rand::thread_rng().r#gen();
let room_alias = format!("aliasy_mac_alias{suffix}");
let room = alice
@@ -1142,13 +1143,15 @@ async fn test_room_preview_with_room_directory_search_and_room_alias_only() {
.await;
// Given a successful public room search
let chunks = vec![PublicRoomsChunkInit {
num_joined_members: uint!(0),
room_id: expected_room_id.to_owned(),
world_readable: true,
guest_can_join: true,
}
.into()];
let chunks = vec![
PublicRoomsChunkInit {
num_joined_members: uint!(0),
room_id: expected_room_id.to_owned(),
world_readable: true,
guest_can_join: true,
}
.into(),
];
server.mock_public_rooms().ok(chunks, None, None, Some(1)).mock_once().mount().await;
// The room preview is found
@@ -1184,24 +1187,28 @@ async fn test_room_preview_with_room_directory_search_and_room_alias_only_in_sev
(
via_1.to_owned(),
// The actual room we want
vec![PublicRoomsChunkInit {
num_joined_members: uint!(0),
room_id: expected_room_id.to_owned(),
world_readable: true,
guest_can_join: true,
}
.into()],
vec![
PublicRoomsChunkInit {
num_joined_members: uint!(0),
room_id: expected_room_id.to_owned(),
world_readable: true,
guest_can_join: true,
}
.into(),
],
),
(
via_2.to_owned(),
// Some other room
vec![PublicRoomsChunkInit {
num_joined_members: uint!(1),
room_id: owned_room_id!("!some-other-room:matrix.org"),
world_readable: true,
guest_can_join: true,
}
.into()],
vec![
PublicRoomsChunkInit {
num_joined_members: uint!(1),
room_id: owned_room_id!("!some-other-room:matrix.org"),
world_readable: true,
guest_can_join: true,
}
.into(),
],
),
]);
server
@@ -22,27 +22,26 @@ use eyeball_im::{Vector, VectorDiff};
use futures::pin_mut;
use futures_util::{FutureExt, StreamExt};
use matrix_sdk::{
assert_next_with_timeout,
Client, Room, RoomState, assert_next_with_timeout,
config::SyncSettings,
deserialized_responses::{VerificationLevel, VerificationState},
encryption::{backups::BackupState, EncryptionSettings},
encryption::{EncryptionSettings, backups::BackupState},
room::edit::EditedContent,
ruma::{
MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId, UserId,
api::client::room::create_room::v3::{Request as CreateRoomRequest, RoomPreset},
events::{
room::{encryption::RoomEncryptionEventContent, message::RoomMessageEventContent},
InitialStateEvent,
room::{encryption::RoomEncryptionEventContent, message::RoomMessageEventContent},
},
MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId, UserId,
},
Client, Room, RoomState,
};
use matrix_sdk_ui::{
Timeline,
notification_client::NotificationClient,
room_list_service::RoomListLoadingState,
sync_service::SyncService,
timeline::{EventSendState, EventTimelineItem, ReactionStatus, RoomExt, TimelineItem},
Timeline,
};
use similar_asserts::assert_eq;
use stream_assert::assert_pending;
@@ -397,9 +396,10 @@ async fn test_enabling_backups_retries_decryption() {
debug!("Creating room…");
let initial_state =
vec![InitialStateEvent::new(RoomEncryptionEventContent::with_recommended_defaults())
.to_raw_any()];
let initial_state = vec![
InitialStateEvent::new(RoomEncryptionEventContent::with_recommended_defaults())
.to_raw_any(),
];
let room = alice
.create_room(assign!(CreateRoomRequest::new(), {
@@ -410,11 +410,12 @@ async fn test_enabling_backups_retries_decryption() {
.await
.unwrap();
assert!(room
.latest_encryption_state()
.await
.expect("We should be able to check that the room is encrypted")
.is_encrypted());
assert!(
room.latest_encryption_state()
.await
.expect("We should be able to check that the room is encrypted")
.is_encrypted()
);
let event_id = room
.send(RoomMessageEventContent::text_plain("It's a secret to everybody!"))
@@ -533,9 +534,10 @@ async fn test_room_keys_received_on_notification_client_trigger_redecryption() {
debug!("Creating the room…");
// The room needs to be encrypted.
let initial_state =
vec![InitialStateEvent::new(RoomEncryptionEventContent::with_recommended_defaults())
.to_raw_any()];
let initial_state = vec![
InitialStateEvent::new(RoomEncryptionEventContent::with_recommended_defaults())
.to_raw_any(),
];
let alice_room = alice
.create_room(assign!(CreateRoomRequest::new(), {
@@ -546,11 +548,13 @@ async fn test_room_keys_received_on_notification_client_trigger_redecryption() {
.await
.unwrap();
assert!(alice_room
.latest_encryption_state()
.await
.expect("We should be able to check that the room is encrypted")
.is_encrypted());
assert!(
alice_room
.latest_encryption_state()
.await
.expect("We should be able to check that the room is encrypted")
.is_encrypted()
);
// Create stream listening for devices.
let devices_stream = alice
@@ -795,11 +799,12 @@ async fn test_new_users_first_messages_dont_warn_about_insecure_device_if_it_is_
.await
.expect("should not fail to create room");
assert!(room
.latest_encryption_state()
.await
.expect("should be able to check that the room is encrypted")
.is_encrypted());
assert!(
room.latest_encryption_state()
.await
.expect("should be able to check that the room is encrypted")
.is_encrypted()
);
room
}
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
authors = ["stoically <stoically@protonmail.com>"]
description = "Helper macros to write tests for the Matrix SDK"
edition = "2021"
edition = "2024"
homepage = "https://github.com/matrix-org/matrix-rust-sdk"
keywords = ["matrix", "chat", "messaging", "ruma"]
license = "Apache-2.0"
+1 -1
View File
@@ -1,5 +1,5 @@
use proc_macro::TokenStream;
use quote::{format_ident, quote, ToTokens};
use quote::{ToTokens, format_ident, quote};
use syn::parse_macro_input;
/// Attribute to use `wasm_bindgen_test` for wasm32 targets and `tokio::test`
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
authors = ["Damir Jelić <poljar@termina.org.uk>"]
description = "Helpers to write tests for the Matrix SDK"
edition = "2021"
edition = "2024"
homepage = "https://github.com/matrix-org/matrix-rust-sdk"
keywords = ["matrix", "chat", "messaging", "ruma"]
license = "Apache-2.0"
+14 -12
View File
@@ -24,12 +24,18 @@ use matrix_sdk_common::deserialized_responses::{
TimelineEvent, UnableToDecryptInfo, UnableToDecryptReason,
};
use ruma::{
EventId, Int, MilliSecondsSinceUnixEpoch, MxcUri, OwnedEventId, OwnedMxcUri, OwnedRoomAliasId,
OwnedRoomId, OwnedTransactionId, OwnedUserId, OwnedVoipId, RoomId, RoomVersionId,
TransactionId, UInt, UserId, VoipVersionId,
events::{
AnyMessageLikeEvent, AnyStateEvent, AnySyncStateEvent, AnySyncTimelineEvent,
AnyTimelineEvent, BundledMessageLikeRelations, Mentions, RedactedMessageLikeEventContent,
RedactedStateEventContent, StateEventContent, StaticEventContent,
beacon::BeaconEventContent,
call::{
SessionDescription,
invite::CallInviteEventContent,
notify::{ApplicationType, CallNotifyEventContent, NotifyType},
SessionDescription,
},
member_hints::MemberHintsEventContent,
poll::{
@@ -44,6 +50,7 @@ use ruma::{
receipt::{Receipt, ReceiptEventContent, ReceiptThread, ReceiptType},
relation::{Annotation, BundledThread, InReplyTo, Replacement, Thread},
room::{
ImageInfo,
avatar::{self, RoomAvatarEventContent},
canonical_alias::RoomCanonicalAliasEventContent,
create::{PreviousRoom, RoomCreateEventContent},
@@ -60,18 +67,12 @@ use ruma::{
server_acl::RoomServerAclEventContent,
tombstone::RoomTombstoneEventContent,
topic::RoomTopicEventContent,
ImageInfo,
},
sticker::StickerEventContent,
typing::TypingEventContent,
AnyMessageLikeEvent, AnyStateEvent, AnySyncStateEvent, AnySyncTimelineEvent,
AnyTimelineEvent, BundledMessageLikeRelations, Mentions, RedactedMessageLikeEventContent,
RedactedStateEventContent, StateEventContent, StaticEventContent,
},
serde::Raw,
server_name, EventId, Int, MilliSecondsSinceUnixEpoch, MxcUri, OwnedEventId, OwnedMxcUri,
OwnedRoomAliasId, OwnedRoomId, OwnedTransactionId, OwnedUserId, OwnedVoipId, RoomId,
RoomVersionId, TransactionId, UInt, UserId, VoipVersionId,
server_name,
};
use serde::Serialize;
use serde_json::json;
@@ -554,8 +555,8 @@ impl EventFactory {
/// use matrix_sdk_test::event_factory::EventFactory;
/// use ruma::{
/// events::{
/// room::member::{MembershipState, RoomMemberEventContent},
/// SyncStateEvent,
/// room::member::{MembershipState, RoomMemberEventContent},
/// },
/// room_id,
/// serde::Raw,
@@ -626,7 +627,7 @@ impl EventFactory {
///
/// use matrix_sdk_test::event_factory::EventFactory;
/// use ruma::{
/// events::{member_hints::MemberHintsEventContent, SyncStateEvent},
/// events::{SyncStateEvent, member_hints::MemberHintsEventContent},
/// owned_user_id, room_id,
/// serde::Raw,
/// user_id,
@@ -892,10 +893,11 @@ impl EventFactory {
/// ```
/// use matrix_sdk_test::event_factory::EventFactory;
/// use ruma::{
/// events::{beacon::BeaconEventContent, MessageLikeEvent},
/// MilliSecondsSinceUnixEpoch,
/// events::{MessageLikeEvent, beacon::BeaconEventContent},
/// owned_event_id, room_id,
/// serde::Raw,
/// user_id, MilliSecondsSinceUnixEpoch,
/// user_id,
/// };
///
/// let factory = EventFactory::new().room(room_id!("!test:localhost"));
+6 -5
View File
@@ -2,10 +2,11 @@ use http::Response;
pub use matrix_sdk_test_macros::async_test;
use once_cell::sync::Lazy;
use ruma::{
RoomId, UserId,
api::{
client::sync::sync_events::v3::Response as SyncResponse, IncomingResponse, OutgoingResponse,
IncomingResponse, OutgoingResponse, client::sync::sync_events::v3::Response as SyncResponse,
},
room_id, user_id, RoomId, UserId,
room_id, user_id,
};
use serde_json::Value as JsonValue;
@@ -120,9 +121,9 @@ mod sync_builder;
pub mod test_json;
pub use self::sync_builder::{
bulk_room_members, GlobalAccountDataTestEvent, InvitedRoomBuilder, JoinedRoomBuilder,
KnockedRoomBuilder, LeftRoomBuilder, PresenceTestEvent, RoomAccountDataTestEvent,
StateTestEvent, StrippedStateTestEvent, SyncResponseBuilder,
GlobalAccountDataTestEvent, InvitedRoomBuilder, JoinedRoomBuilder, KnockedRoomBuilder,
LeftRoomBuilder, PresenceTestEvent, RoomAccountDataTestEvent, StateTestEvent,
StrippedStateTestEvent, SyncResponseBuilder, bulk_room_members,
};
pub static ALICE: Lazy<&UserId> = Lazy::new(|| user_id!("@alice:server.name"));
+1 -1
View File
@@ -15,8 +15,8 @@
//! Mocks useful to reuse across different testing contexts.
use wiremock::{
matchers::{header, method, path_regex},
Mock, MockServer, ResponseTemplate,
matchers::{header, method, path_regex},
};
use crate::test_json;
@@ -1,9 +1,9 @@
use ruma::{
RoomId, UserId,
push::{
Action, NewConditionalPushRule, NewPushRule, NewSimplePushRule, PushCondition, RuleKind,
Ruleset, Tweak,
},
RoomId, UserId,
};
pub fn get_server_default_ruleset() -> Ruleset {
@@ -1,7 +1,7 @@
use std::ops::Range;
use ruma::{
events::{room::member::MembershipState, AnySyncStateEvent},
events::{AnySyncStateEvent, room::member::MembershipState},
serde::Raw,
};
use serde_json::{from_value as from_json_value, json};
@@ -1,6 +1,6 @@
use ruma::{
api::client::sync::sync_events::v3::InvitedRoom, events::AnyStrippedStateEvent, serde::Raw,
OwnedRoomId, RoomId,
OwnedRoomId, RoomId, api::client::sync::sync_events::v3::InvitedRoom,
events::AnyStrippedStateEvent, serde::Raw,
};
use super::StrippedStateTestEvent;
@@ -1,16 +1,16 @@
use ruma::{
OwnedRoomId, RoomId,
api::client::sync::sync_events::v3::JoinedRoom,
events::{
receipt::ReceiptEventContent, typing::TypingEventContent, AnyRoomAccountDataEvent,
AnySyncStateEvent, AnySyncTimelineEvent,
AnyRoomAccountDataEvent, AnySyncStateEvent, AnySyncTimelineEvent,
receipt::ReceiptEventContent, typing::TypingEventContent,
},
serde::Raw,
OwnedRoomId, RoomId,
};
use serde_json::{from_value as from_json_value, Value as JsonValue};
use serde_json::{Value as JsonValue, from_value as from_json_value};
use super::RoomAccountDataTestEvent;
use crate::{event_factory::EventBuilder, DEFAULT_TEST_ROOM_ID};
use crate::{DEFAULT_TEST_ROOM_ID, event_factory::EventBuilder};
pub struct JoinedRoomBuilder {
pub(super) room_id: OwnedRoomId,
@@ -1,6 +1,6 @@
use ruma::{
api::client::sync::sync_events::v3::KnockedRoom, events::AnyStrippedStateEvent, serde::Raw,
OwnedRoomId, RoomId,
OwnedRoomId, RoomId, api::client::sync::sync_events::v3::KnockedRoom,
events::AnyStrippedStateEvent, serde::Raw,
};
use super::StrippedStateTestEvent;
@@ -1,8 +1,8 @@
use ruma::{
OwnedRoomId, RoomId,
api::client::sync::sync_events::v3::LeftRoom,
events::{AnyRoomAccountDataEvent, AnySyncStateEvent, AnySyncTimelineEvent},
serde::Raw,
OwnedRoomId, RoomId,
};
use super::{RoomAccountDataTestEvent, StateTestEvent};
@@ -2,17 +2,17 @@ use std::collections::HashMap;
use http::Response;
use ruma::{
OwnedRoomId, OwnedUserId, UserId,
api::{
IncomingResponse,
client::sync::sync_events::v3::{
InvitedRoom, JoinedRoom, KnockedRoom, LeftRoom, Response as SyncResponse,
},
IncomingResponse,
},
events::{presence::PresenceEvent, AnyGlobalAccountDataEvent, AnyToDeviceEvent},
events::{AnyGlobalAccountDataEvent, AnyToDeviceEvent, presence::PresenceEvent},
serde::Raw,
OwnedRoomId, OwnedUserId, UserId,
};
use serde_json::{from_value as from_json_value, json, Value as JsonValue};
use serde_json::{Value as JsonValue, from_value as from_json_value, json};
use super::test_json;
@@ -1,11 +1,11 @@
use ruma::{
events::{
presence::PresenceEvent, AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent,
AnyStrippedStateEvent, AnySyncStateEvent,
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent,
AnySyncStateEvent, presence::PresenceEvent,
},
serde::Raw,
};
use serde_json::{from_value as from_json_value, Value as JsonValue};
use serde_json::{Value as JsonValue, from_value as from_json_value};
use crate::test_json;
@@ -1,7 +1,7 @@
//! Responses to client API calls.
use once_cell::sync::Lazy;
use serde_json::{json, Value as JsonValue};
use serde_json::{Value as JsonValue, json};
/// `GET /_matrix/client/v3/devices`
pub static DEVICES: Lazy<JsonValue> = Lazy::new(|| {
@@ -19,8 +19,8 @@
use std::{collections::HashMap, iter};
use ruma::{
api::client::keys::get_keys::v3::Response as KeyQueryResponse, device_id, user_id, DeviceId,
UserId,
DeviceId, UserId, api::client::keys::get_keys::v3::Response as KeyQueryResponse, device_id,
user_id,
};
use serde_json::json;
@@ -2,18 +2,19 @@ use std::{collections::BTreeMap, default::Default};
use insta::{assert_json_snapshot, with_settings};
use ruma::{
CanonicalJsonValue, CrossSigningKeyId, CrossSigningOrDeviceSignatures,
CrossSigningOrDeviceSigningKeyId, DeviceId, OwnedBase64PublicKey,
OwnedBase64PublicKeyOrDeviceId, OwnedDeviceId, OwnedUserId, SigningKeyAlgorithm, UserId,
api::client::keys::get_keys::v3::Response as KeyQueryResponse,
device_id,
encryption::{CrossSigningKey, DeviceKeys, KeyUsage},
serde::Raw,
user_id, CanonicalJsonValue, CrossSigningKeyId, CrossSigningOrDeviceSignatures,
CrossSigningOrDeviceSigningKeyId, DeviceId, OwnedBase64PublicKey,
OwnedBase64PublicKeyOrDeviceId, OwnedDeviceId, OwnedUserId, SigningKeyAlgorithm, UserId,
user_id,
};
use serde_json::{json, Value};
use serde_json::{Value, json};
use vodozemac::{Curve25519PublicKey, Ed25519PublicKey, Ed25519SecretKey, Ed25519Signature};
use super::keys_query::{keys_query, master_keys, KeysQueryUser};
use super::keys_query::{KeysQueryUser, keys_query, master_keys};
use crate::{
ruma_response_from_json, ruma_response_to_json,
test_json::keys_query::{device_keys_payload, self_signing_keys},
@@ -1,7 +1,7 @@
//! Example responses to `GET /_matrix/client/v3/rooms/{roomId}/members`
use once_cell::sync::Lazy;
use serde_json::{json, Value as JsonValue};
use serde_json::{Value as JsonValue, json};
use super::DEFAULT_TEST_ROOM_ID;
+1 -1
View File
@@ -5,7 +5,7 @@
//! the test data needs to be contained within this crate.
use once_cell::sync::Lazy;
use serde_json::{json, Value as JsonValue};
use serde_json::{Value as JsonValue, json};
use crate::DEFAULT_TEST_ROOM_ID;
@@ -1,5 +1,5 @@
use once_cell::sync::Lazy;
use serde_json::{json, Value as JsonValue};
use serde_json::{Value as JsonValue, json};
pub static SEARCH_USERS_REQUEST: Lazy<JsonValue> = Lazy::new(|| {
json!({
@@ -1,8 +1,8 @@
//! Complete sync responses.
use once_cell::sync::Lazy;
use ruma::{room_id, RoomId};
use serde_json::{json, Value as JsonValue};
use ruma::{RoomId, room_id};
use serde_json::{Value as JsonValue, json};
use crate::DEFAULT_TEST_ROOM_ID;
@@ -1,7 +1,7 @@
//! Discrete events found in a sync response.
use once_cell::sync::Lazy;
use serde_json::{json, Value as JsonValue};
use serde_json::{Value as JsonValue, json};
use crate::DEFAULT_TEST_ROOM_ID;