@@ -1967,6 +1967,17 @@ mod tests {
19671967 // We sort the sessions in the bundle, so that the snapshot is stable.
19681968 bundle. room_keys . sort_by_key ( |session| session. session_id . clone ( ) ) ;
19691969
1970+ // We substitute the algorithm, since this changes based on feature flags.
1971+ let algorithm = if cfg ! ( feature = "experimental-algorithms" ) {
1972+ "m.megolm.v2.aes-sha2"
1973+ } else {
1974+ "m.megolm.v1.aes-sha2"
1975+ } ;
1976+ let map_algorithm = move |value : Content , _path : ContentPath < ' _ > | {
1977+ assert_eq ! ( value. as_str( ) . unwrap( ) , algorithm) ;
1978+ "[algorithm]"
1979+ } ;
1980+
19701981 // We also substitute alice's keys in the snapshot with placeholders
19711982 let alice_curve_key = alice. identity_keys ( ) . curve25519 . to_base64 ( ) ;
19721983 let map_alice_curve_key = move |value : Content , _path : ContentPath < ' _ > | {
@@ -1981,6 +1992,8 @@ mod tests {
19811992
19821993 insta:: with_settings!( { sort_maps => true } , {
19831994 assert_json_snapshot!( bundle, {
1995+ ".withheld[].algorithm" => insta:: dynamic_redaction( map_algorithm) ,
1996+ ".room_keys[].algorithm" => insta:: dynamic_redaction( map_algorithm) ,
19841997 ".room_keys[].sender_key" => insta:: dynamic_redaction( map_alice_curve_key. clone( ) ) ,
19851998 ".withheld[].sender_key" => insta:: dynamic_redaction( map_alice_curve_key) ,
19861999 ".room_keys[].sender_claimed_keys.ed25519" => insta:: dynamic_redaction( map_alice_ed25519_key) ,
@@ -2036,6 +2049,12 @@ mod tests {
20362049 ///
20372050 /// `olm_machine` is used to set the `sender_key` and `signing_key`
20382051 /// fields of the resultant session.
2052+ ///
2053+ /// The encryption algorithm used for the session depends on the
2054+ /// `experimental-algorithms` feature flag:
2055+ ///
2056+ /// - When not set, the session uses `m.megolm.v1.aes-sha2`.
2057+ /// - When set, the session uses `m.megolm.v2.aes-sha2`.
20392058 fn create_inbound_group_session_with_visibility (
20402059 olm_machine : & OlmMachine ,
20412060 room_id : & RoomId ,
@@ -2049,7 +2068,10 @@ mod tests {
20492068 room_id,
20502069 session_key,
20512070 SenderData :: unknown ( ) ,
2071+ #[ cfg( not( feature = "experimental-algorithms" ) ) ]
20522072 EventEncryptionAlgorithm :: MegolmV1AesSha2 ,
2073+ #[ cfg( feature = "experimental-algorithms" ) ]
2074+ EventEncryptionAlgorithm :: MegolmV2AesSha2 ,
20532075 None ,
20542076 shared_history,
20552077 )
0 commit comments