diff --git a/src/olm/account/mod.rs b/src/olm/account/mod.rs index 9306f4bd..a033faa0 100644 --- a/src/olm/account/mod.rs +++ b/src/olm/account/mod.rs @@ -1479,4 +1479,29 @@ mod test { Ok(()) } + + #[test] + fn fails_to_rehydrate_with_wrong_key() -> Result<()> { + let mut alice = Account::new(); + + alice.generate_one_time_keys(alice.max_number_of_one_time_keys()); + alice.generate_fallback_key(); + + let alice_dehydrated = + alice.to_dehydrated_device(&PICKLE_KEY).expect("Should be able to dehydrate device"); + + assert!(Account::from_dehydrated_device( + &alice_dehydrated, + &alice.curve25519_key().to_base64(), + &[1; 32], + ).is_err()); + + assert!(Account::from_dehydrated_device( + &alice_dehydrated, + &"WrongDeviceID", + &PICKLE_KEY, + ).is_err()); + + Ok(()) + } }