openmls/test_utils/single_group_test_framework/
assertions.rs1use super::*;
2
3impl<Provider: OpenMlsProvider> MemberState<'_, Provider> {
4 pub fn assert_group_storage_state_matches(&self, to_compare: GroupStorageState) {
5 let state_now = self.group_storage_state();
6 assert!(to_compare == state_now);
7 }
8 pub fn assert_non_proposal_group_storage_state_matches(&self, to_compare: GroupStorageState) {
9 let state_now = self.group_storage_state();
10 assert!(to_compare.non_proposal_state() == state_now.non_proposal_state());
11 }
12}
13impl<Provider: OpenMlsProvider> GroupState<'_, Provider> {
14 pub fn assert_membership(&self) {
15 let mut names = self
16 .members
17 .keys()
18 .map(|s| s.to_string())
19 .collect::<Vec<_>>();
20 names.sort();
21
22 for state in self.members.values() {
23 let mut names_in_group = state
24 .group
25 .members()
26 .map(|member| {
27 let credential: BasicCredential = member.credential.try_into().unwrap();
28
29 String::from_utf8(credential.identity().to_owned()).unwrap()
30 })
31 .collect::<Vec<_>>();
32
33 names_in_group.sort();
34
35 assert_eq!(names, names_in_group);
36 }
37 }
38}