diff --git a/src/crypto/olm.rs b/src/crypto/olm.rs index f641ecb7..72e28b2d 100644 --- a/src/crypto/olm.rs +++ b/src/crypto/olm.rs @@ -232,7 +232,7 @@ impl PartialEq for Account { /// /// Sessions are used to exchange encrypted messages between two /// accounts/devices. -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Session { inner: Arc>, session_id: Arc, @@ -241,6 +241,15 @@ pub struct Session { pub(crate) last_use_time: Arc, } +impl fmt::Debug for Session { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Session") + .field("session_id", &self.session_id()) + .field("sender_key", &self.sender_key) + .finish() + } +} + impl Session { /// Decrypt the given Olm message. /// @@ -688,10 +697,15 @@ mod test { let bob_keys = bob.identity_keys(); let mut alice_session = alice - .create_inbound_session(bob_keys.curve25519(), prekey_message) + .create_inbound_session(bob_keys.curve25519(), prekey_message.clone()) .await .unwrap(); + assert!(alice_session + .matches(bob_keys.curve25519(), prekey_message) + .await + .unwrap()); + assert_eq!(bob_session.session_id(), alice_session.session_id()); let decyrpted = alice_session.decrypt(message).await.unwrap();