Skip to content

Commit 36f74ed

Browse files
committed
test: snapshot test for HistoricRoomKey::debug
1 parent 27bfeb8 commit 36f74ed

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

crates/matrix-sdk-crypto/src/types/room_history.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,28 @@ impl From<ExportedRoomKey> for HistoricRoomKey {
112112
}
113113
}
114114
}
115+
116+
#[cfg(test)]
117+
mod tests {
118+
use insta::assert_debug_snapshot;
119+
use ruma::{owned_room_id, DeviceKeyAlgorithm};
120+
use vodozemac::{
121+
megolm::ExportedSessionKey, Curve25519PublicKey, Curve25519SecretKey, Ed25519SecretKey,
122+
};
123+
124+
use crate::types::{room_history::HistoricRoomKey, EventEncryptionAlgorithm};
125+
126+
#[test]
127+
fn test_historic_room_key_debug() {
128+
let key = HistoricRoomKey {
129+
algorithm: EventEncryptionAlgorithm::MegolmV1AesSha2,
130+
room_id: owned_room_id!("!room:id"),
131+
sender_key: Curve25519PublicKey::from(&Curve25519SecretKey::from_slice(b"abcdabcdabcdabcdabcdabcdabcdabcd")),
132+
session_id: "id1234".to_owned(),
133+
session_key: ExportedSessionKey::from_base64("AQAAAAC2XHVzsMBKs4QCRElJ92CJKyGtknCSC8HY7cQ7UYwndMKLQAejXLh5UA0l6s736mgctcUMNvELScUWrObdflrHo+vth/gWreXOaCnaSxmyjjKErQwyIYTkUfqbHy40RJfEesLwnN23on9XAkch/iy8R2+Jz7B8zfG01f2Ow2SxPQFnAndcO1ZSD2GmXgedy6n4B20MWI1jGP2wiexOWbFS").unwrap(),
134+
sender_claimed_keys: vec![(DeviceKeyAlgorithm::Ed25519, Ed25519SecretKey::from_slice(b"abcdabcdabcdabcdabcdabcdabcdabcd").public_key().into())].into_iter().collect(),
135+
};
136+
137+
assert_debug_snapshot!(key);
138+
}
139+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
source: crates/matrix-sdk-crypto/src/types/room_history.rs
3+
expression: key
4+
---
5+
SharedRoomKey {
6+
algorithm: "m.megolm.v1.aes-sha2",
7+
room_id: "!room:id",
8+
sender_key: "curve25519:2n4iKRAGOTwcw54MuivfjtU/KZl1Fslme/b1FZMMRQM",
9+
session_id: "id1234",
10+
sender_claimed_keys: SigningKeys(
11+
{
12+
"ed25519": Ed25519(
13+
"ed25519:kbNLK/pAgXV57gwDRd/0TjMp4BsqwtWXgPmSxgHVnpk",
14+
),
15+
},
16+
),
17+
..
18+
}

0 commit comments

Comments
 (0)