-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a Replace proposal #174
base: main
Are you sure you want to change the base?
Changes from all commits
a9395e3
17740df
6bb2247
66e5ed8
19d9341
6079c58
c6f93e7
0130e04
cfc536e
62ded9d
494179f
1269317
2e41ed7
78ac756
251f823
2096668
890945f
21b682f
8fc1de2
4d70372
a0f8dcf
c864672
6c4ad02
9ae9682
eb8dd52
75f265d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,6 +197,19 @@ where | |
Ok(self) | ||
} | ||
|
||
/// Insert a [`ReplaceProposal`](crate::group::proposal::ReplaceProposal) into | ||
/// the current commit that is being built. | ||
#[cfg(feature = "replace_proposal")] | ||
pub fn replace_member( | ||
mut self, | ||
to_replace: u32, | ||
leaf_node: LeafNode, | ||
) -> Result<Self, MlsError> { | ||
Comment on lines
+203
to
+207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a public interface to obtain the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, to date we have made LeafNode private, maybe it should stay private? |
||
let proposal = self.group.replace_proposal(to_replace, leaf_node)?; | ||
self.proposals.push(proposal); | ||
Ok(self) | ||
} | ||
|
||
/// Insert a | ||
/// [`GroupContextExtensions`](crate::group::proposal::Proposal::GroupContextExtensions) | ||
/// into the current commit that is being built. | ||
|
@@ -1017,6 +1030,54 @@ mod tests { | |
assert_commit_builder_output(group, commit_output, vec![expected_remove], 0); | ||
} | ||
|
||
#[cfg(feature = "replace_proposal")] | ||
#[maybe_async::test(not(mls_build_async), async(mls_build_async, crate::futures_test))] | ||
async fn test_commit_builder_replace() -> Result<(), MlsError> { | ||
let mut group = test_group_custom_config(TEST_PROTOCOL_VERSION, TEST_CIPHER_SUITE, |b| { | ||
b.custom_proposal_type(ProposalType::REPLACE) | ||
}) | ||
.await | ||
.group; | ||
|
||
let (alice, alice_kp) = | ||
test_client_with_key_pkg(TEST_PROTOCOL_VERSION, TEST_CIPHER_SUITE, "alice").await; | ||
|
||
// Add Alice to the group | ||
let output = group | ||
.commit_builder() | ||
.add_member(alice_kp.clone()) | ||
.unwrap() | ||
.build() | ||
.await?; | ||
|
||
group.apply_pending_commit().await?; | ||
|
||
// Alice creates an Update proposal, including a fresh LeafNode | ||
let (mut alice_group, _) = alice.join_group(None, &output.welcome_messages[0])?; | ||
let proposal = alice_group.update_proposal(None, None)?; | ||
let Proposal::Update(update) = proposal else { | ||
panic!("non update proposal found") | ||
}; | ||
|
||
// The committer replaces Alice's appearance in the group | ||
let commit_output = group | ||
.commit_builder() | ||
.replace_member(1, update.leaf_node.clone())? | ||
.build() | ||
.await?; | ||
|
||
let expected_replace = group.replace_proposal(1, update.leaf_node)?; | ||
|
||
assert_commit_builder_output( | ||
group.clone(), | ||
commit_output.clone(), | ||
vec![expected_replace], | ||
0, | ||
); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[cfg(feature = "psk")] | ||
#[maybe_async::test(not(mls_build_async), async(mls_build_async, crate::futures_test))] | ||
async fn test_commit_builder_psk() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious if this should be default or not just because the feature is on? I think I view the feature more as "you can possibly do this" vs "you definitely want to do this"