From 10c2c4f9161f370c72630c87b33d921f2f4ede18 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:43:25 -0700 Subject: [PATCH] Add test for incorrect max_past_epochs value --- openmls/src/group/mls_group/past_secrets.rs | 2 +- .../tests_and_kats/tests/mls_group.rs | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/openmls/src/group/mls_group/past_secrets.rs b/openmls/src/group/mls_group/past_secrets.rs index e3e878717..9948d45d7 100644 --- a/openmls/src/group/mls_group/past_secrets.rs +++ b/openmls/src/group/mls_group/past_secrets.rs @@ -21,7 +21,7 @@ struct EpochTree { #[cfg_attr(feature = "crypto-debug", derive(Debug))] pub(crate) struct MessageSecretsStore { // Maximum size of the `past_epoch_trees` list. - max_epochs: usize, + pub(crate) max_epochs: usize, // Past message secrets. past_epoch_trees: VecDeque, // The message secrets of the current epoch. diff --git a/openmls/src/group/mls_group/tests_and_kats/tests/mls_group.rs b/openmls/src/group/mls_group/tests_and_kats/tests/mls_group.rs index 9f2c8604b..f7cae4711 100644 --- a/openmls/src/group/mls_group/tests_and_kats/tests/mls_group.rs +++ b/openmls/src/group/mls_group/tests_and_kats/tests/mls_group.rs @@ -1156,6 +1156,34 @@ fn remove_prosposal_by_ref( } } +#[openmls_test] +fn max_past_epochs_join_config( + ciphersuite: Ciphersuite, + provider: &impl crate::storage::OpenMlsProvider, +) { + let max_past_epochs = 10; + + let create_config = MlsGroupCreateConfig::builder() + .max_past_epochs(max_past_epochs) + .build(); + + let (alice_credential_with_key, _alice_kpb, alice_signer, _alice_pk) = + setup_client("Alice", ciphersuite, provider); + + let alice_group = MlsGroup::new( + provider, + &alice_signer, + &create_config, + alice_credential_with_key, + ) + .expect("failed to create group"); + + assert_eq!( + alice_group.message_secrets_store.max_epochs, + max_past_epochs + ); +} + // Test that the builder pattern accurately configures the new group. #[openmls_test] fn builder_pattern() {