Skip to content

Commit

Permalink
Make CommitProcessor another variant of ReceivedMessage. Remove comm…
Browse files Browse the repository at this point in the history
…it_processor function
  • Loading branch information
Marta Mularczyk committed Jan 16, 2025
1 parent 1c124a0 commit 8571ef5
Show file tree
Hide file tree
Showing 12 changed files with 318 additions and 217 deletions.
9 changes: 7 additions & 2 deletions mls-rs/examples/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use mls_rs::{
error::MlsError,
group::{
proposal::{MlsCustomProposal, Proposal},
GroupContext, Sender,
GroupContext, ReceivedMessage, Sender,
},
mls_rules::{ProposalBundle, ProposalSource},
CipherSuite, CipherSuiteProvider, Client, CryptoProvider, ExtensionList, IdentityProvider,
Expand Down Expand Up @@ -408,7 +408,12 @@ fn main() -> Result<(), CustomError> {

alice_tablet_group.apply_pending_commit()?;

let mut processor = alice_pc_group.commit_processor(commit.commit_message)?;
let ReceivedMessage::CommitProcessor(mut processor) =
alice_pc_group.process_incoming_message(commit.commit_message)?
else {
return Err(CustomError);
};

handle_custom_proposals(&processor.context().clone(), processor.proposals_mut())?;
processor.process()?;

Expand Down
12 changes: 6 additions & 6 deletions mls-rs/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,10 +1020,9 @@ mod tests {

assert_eq!(new_group.roster().members_iter().count(), num_members);

let _ = alice_group
alice_group
.commit_processor(external_commit.clone())
.await
.unwrap()
.with_external_psk(psk_id.clone(), psk.clone())
.process()
.await
Expand All @@ -1034,7 +1033,6 @@ mod tests {
let message = bob_group
.commit_processor(external_commit.clone())
.await
.unwrap()
.with_external_psk(psk_id, psk)
.process()
.await
Expand All @@ -1045,9 +1043,6 @@ mod tests {
if !do_remove {
assert!(bob_group.roster().members_iter().count() == num_members);
} else {
// Bob was removed so his epoch must stay the same
assert_eq!(bob_group.current_epoch(), bob_current_epoch);

assert_matches!(
message,
CommitMessageDescription {
Expand All @@ -1058,6 +1053,11 @@ mod tests {
..
}
);

core::mem::drop(message);

// Bob was removed so his epoch must stay the same
assert_eq!(bob_group.current_epoch(), bob_current_epoch);
}

// Comparing epoch authenticators is sufficient to check that members are in sync.
Expand Down
Loading

0 comments on commit 8571ef5

Please sign in to comment.