Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
beltram committed Nov 24, 2023
1 parent 4262efa commit 2bf99b1
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions crypto/src/mls/conversation/decrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ use openmls::{
},
};
use openmls_traits::OpenMlsCryptoProvider;
use tls_codec::Deserialize;

use core_crypto_keystore::entities::MlsPendingMessage;
use mls_crypto_provider::MlsCryptoProvider;
use tls_codec::Deserialize;

use crate::{
group_store::GroupStoreValue,
Expand Down Expand Up @@ -327,17 +327,20 @@ impl MlsCentral {

#[cfg(test)]
pub mod tests {
use super::*;
use std::time::Duration;

use openmls::prelude::{KeyPackageRef, ProcessMessageError};
use openmls_traits::OpenMlsCryptoProvider;
use wasm_bindgen_test::*;

use crate::mls::conversation::config::MAX_PAST_EPOCHS;
use crate::{
prelude::{handshake::MlsCommitBundle, MemberId, MlsWirePolicy},
test_utils::{ValidationCallbacks, *},
CryptoError,
};
use openmls::prelude::{KeyPackageRef, ProcessMessageError};
use openmls_traits::OpenMlsCryptoProvider;
use std::time::Duration;
use wasm_bindgen_test::*;

use super::*;

wasm_bindgen_test_configure!(run_in_browser);

Expand Down Expand Up @@ -477,8 +480,15 @@ pub mod tests {
.unwrap();
// Now Debbie should be in members and not Charlie
let members = alice_central.get_conversation_unchecked(&id).await.members();
assert!(members.get("debbie".as_bytes()).is_some());
assert!(members.get("charlie".as_bytes()).is_none());

let dc = debbie.unverified_credential();
let debbie_id = dc.credential.identity();
assert!(members.get(debbie_id).is_some());

let cc = charlie.unverified_credential();
let charlie_id = cc.credential.identity();
assert!(members.get(charlie_id).is_none());

// Previous commit to add Charlie has been discarded but its proposals will be renewed
assert!(alice_central.pending_commit(&id).await.is_none());
assert!(decrypted.has_epoch_changed)
Expand Down Expand Up @@ -524,11 +534,13 @@ pub mod tests {
.await
.unwrap();
// So Charlie has not been added to the group
let cc = charlie.unverified_credential();
let charlie_id = cc.credential.identity();
assert!(alice_central
.get_conversation_unchecked(&id)
.await
.members()
.get("charlie".as_bytes())
.get(charlie_id)
.is_none());
// Make sure we are suggesting a commit delay
assert!(delay.is_some());
Expand All @@ -537,10 +549,6 @@ pub mod tests {
assert!(!proposals.is_empty());
assert_eq!(alice_central.pending_proposals(&id).await.len(), 1);
assert!(alice_central.pending_commit(&id).await.is_none());
// assert_eq!(
// commit_epoch.as_u64() + 1,
// proposals.first().unwrap().proposal.epoch().as_u64()
// );

// Let's commit this proposal to see if it works
for p in proposals {
Expand All @@ -559,19 +567,21 @@ pub mod tests {
.get_conversation_unchecked(&id)
.await
.members()
.get("charlie".as_bytes())
.get(charlie_id)
.is_some());

let decrypted = bob_central
.decrypt_message(&id, commit.to_bytes().unwrap())
.await
.unwrap();
// Bob also has Charlie in the group
let cc = charlie.unverified_credential();
let charlie_id = cc.credential.identity();
assert!(bob_central
.get_conversation_unchecked(&id)
.await
.members()
.get("charlie".as_bytes())
.get(charlie_id)
.is_some());
assert!(decrypted.has_epoch_changed);

Expand Down

0 comments on commit 2bf99b1

Please sign in to comment.