Skip to content

Commit

Permalink
removed unwrap in
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronvoell committed Apr 10, 2024
1 parent 7395004 commit 969e6a5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
4 changes: 2 additions & 2 deletions openmls/src/group/core_group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,12 +1045,12 @@ impl CoreGroup {
}

/// Create a new group context extension proposal
pub(crate) fn create_group_context_ext_proposal(
pub(crate) fn create_group_context_ext_proposal<KeyStore: OpenMlsKeyStore>(
&self,
framing_parameters: FramingParameters,
extensions: Extensions,
signer: &impl Signer,
) -> Result<AuthenticatedContent, CreateGroupContextExtProposalError> {
) -> Result<AuthenticatedContent, CreateGroupContextExtProposalError<KeyStore::Error>> {
// Ensure that the group supports all the extensions that are wanted.
let required_extension = extensions
.iter()
Expand Down
8 changes: 4 additions & 4 deletions openmls/src/group/core_group/test_proposals.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use openmls_rust_crypto::OpenMlsRustCrypto;
use openmls_traits::{types::Ciphersuite, OpenMlsProvider};
use openmls_traits::{key_store::OpenMlsKeyStore, types::Ciphersuite, OpenMlsProvider};

use super::CoreGroup;
use crate::{
Expand Down Expand Up @@ -543,9 +543,9 @@ fn test_group_context_extension_proposal_fails(
}

#[apply(ciphersuites_and_providers)]
fn test_group_context_extension_proposal(
fn test_group_context_extension_proposal<KeyStore: OpenMlsKeyStore>(
ciphersuite: Ciphersuite,
provider: &impl OpenMlsProvider,
provider: &impl OpenMlsProvider<KeyStoreProvider = KeyStore>,
) {
// Basic group setup.
let group_aad = b"Alice's test group";
Expand Down Expand Up @@ -617,7 +617,7 @@ fn test_group_context_extension_proposal(
&[CredentialType::Basic],
));
let gce_proposal = alice_group
.create_group_context_ext_proposal(
.create_group_context_ext_proposal::<KeyStore>(
framing_parameters,
Extensions::single(required_application_id),
&alice_signer,
Expand Down
4 changes: 3 additions & 1 deletion openmls/src/group/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ pub(crate) enum CoreGroupParseMessageError {

/// Create group context ext proposal error
#[derive(Error, Debug, PartialEq, Clone)]
pub enum CreateGroupContextExtProposalError {
pub enum CreateGroupContextExtProposalError<KeyStoreError> {
/// See [`LibraryError`] for more details.
#[error(transparent)]
LibraryError(#[from] LibraryError),
Expand All @@ -509,6 +509,8 @@ pub enum CreateGroupContextExtProposalError {
LeafNodeValidation(#[from] LeafNodeValidationError),
#[error(transparent)]
GroupStateError(#[from] MlsGroupStateError),
#[error(transparent)]
CreateCommitError(#[from] CreateCommitError<KeyStoreError>),
}

/// Error merging a commit.
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/group/mls_group/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,5 +322,5 @@ pub enum ProposalError<KeyStoreError> {
ValidationError(#[from] ValidationError),
/// See [`CreateGroupContextExtProposalError`] for more details.
#[error(transparent)]
CreateGroupContextExtProposalError(#[from] CreateGroupContextExtProposalError),
CreateGroupContextExtProposalError(#[from] CreateGroupContextExtProposalError<KeyStoreError>),
}
20 changes: 12 additions & 8 deletions openmls/src/group/mls_group/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,15 @@ impl MlsGroup {
///
/// Returns an error when the group does not support all the required capabilities
/// in the new `extensions`.
pub fn propose_group_context_extensions(
pub fn propose_group_context_extensions<KeyStore: OpenMlsKeyStore>(
&mut self,
provider: &impl OpenMlsProvider,
provider: &impl OpenMlsProvider<KeyStoreProvider = KeyStore>,
extensions: Extensions,
signer: &impl Signer,
) -> Result<(MlsMessageOut, ProposalRef), ProposalError<()>> {
) -> Result<(MlsMessageOut, ProposalRef), ProposalError<KeyStore::Error>> {
self.is_operational()?;

let proposal = self.group.create_group_context_ext_proposal(
let proposal = self.group.create_group_context_ext_proposal::<KeyStore>(
self.framing_parameters(),
extensions,
signer,
Expand All @@ -356,14 +356,18 @@ impl MlsGroup {
Ok((mls_message, proposal_ref))
}

pub fn update_group_context_extensions(
/// Updates group context extensions
///
/// Returns an error when the group does not support all the required capabilities
/// in the new `extensions`.
pub fn update_group_context_extensions<KeyStore: OpenMlsKeyStore>(
&mut self,
provider: &impl OpenMlsProvider,
provider: &impl OpenMlsProvider<KeyStoreProvider = KeyStore>,
extensions: Extensions,
signer: &impl Signer,
) -> Result<
(MlsMessageOut, Option<MlsMessageOut>, Option<GroupInfo>),
CreateGroupContextExtProposalError,
CreateGroupContextExtProposalError<KeyStore::Error>,
> {
self.is_operational()?;

Expand All @@ -377,7 +381,7 @@ impl MlsGroup {
.proposal_store(&self.proposal_store)
.inline_proposals(inline_proposals)
.build();
let create_commit_result = self.group.create_commit(params, provider, signer).unwrap();
let create_commit_result = self.group.create_commit(params, provider, signer)?;

let mls_messages = self.content_to_mls_message(create_commit_result.commit, provider)?;
self.group_state = MlsGroupState::PendingCommit(Box::new(PendingCommitState::Member(
Expand Down

0 comments on commit 969e6a5

Please sign in to comment.