1//! This deals with DS inconsistencies. When a Welcome message is received, the client might have
2//! already deleted its associated KeyPackage (and encryption key).
3//! Feel free to remove this when this is no longer a problem !!!
45#[cfg(test)]
6mod tests {
78use openmls::prelude::KeyPackage;
9use openmls_traits::OpenMlsCryptoProvider;
10use wasm_bindgen_test::*;
1112use super::super::error::Error;
13use crate::test_utils::*;
1415wasm_bindgen_test_configure!(run_in_browser);
1617#[apply(all_cred_cipher)]
18 #[wasm_bindgen_test]
19pub async fn orphan_welcome_should_generate_external_commit(case: TestCase) {
20 run_test_with_client_ids(case.clone(), ["alice", "bob"], move |[alice_central, bob_central]| {
21 Box::pin(async move {
22let id = conversation_id();
2324 alice_central
25 .context
26 .new_conversation(&id, case.credential_type, case.cfg.clone())
27 .await
28.unwrap();
2930let bob = bob_central.rand_key_package(&case).await;
31let bob_kp_ref = KeyPackage::from(bob.clone())
32 .hash_ref(bob_central.context.mls_provider().await.unwrap().crypto())
33 .unwrap();
3435// Alice invites Bob with a KeyPackage...
36alice_central
37 .context
38 .conversation(&id)
39 .await
40.unwrap()
41 .add_members(vec![bob])
42 .await
43.unwrap();
4445// ...Bob deletes locally (with the associated private key) before processing the Welcome
46bob_central.context.delete_keypackages(&[bob_kp_ref]).await.unwrap();
4748let welcome = alice_central.mls_transport.latest_welcome_message().await;
4950// in that case a dedicated error is thrown for clients to identify this case
51 // and rejoin with an external commit
52let process_welcome = bob_central
53 .context
54 .process_welcome_message(welcome.into(), case.custom_cfg())
55 .await;
56assert!(matches!(process_welcome.unwrap_err(), Error::OrphanWelcome));
57 })
58 })
59 .await;
60 }
61}