Skip to content

Commit

Permalink
Simplify and explain test
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhuaaa committed Jul 24, 2024
1 parent ccf4e65 commit fffe60b
Showing 1 changed file with 33 additions and 30 deletions.
63 changes: 33 additions & 30 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2056,17 +2056,9 @@ mod tests {

assert!(stream_messages.is_closed());
}
// User A = AlexDev3 which is on Epoch A
// User B = Alex1 which is on Epoch B
// User A originally created the group
// User A Added User B to the chat
// User A Added User C & User D to the chat
// User A Removed C & D
// User A added Users E & F
// Below are the logs for User B when trying to load

#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
async fn test_can_add_and_remove_forking_group() {
async fn test_can_send_message_when_out_of_sync() {
let alix = new_test_client().await;
let bo = new_test_client().await;
let caro = new_test_client().await;
Expand All @@ -2077,33 +2069,44 @@ mod tests {
// Create group and send first message
let alix_group = alix
.conversations()
.create_group(vec![bo.account_address.clone()], FfiCreateGroupOptions::default())
.create_group(
vec![bo.account_address.clone()],
FfiCreateGroupOptions::default(),
)
.await
.unwrap();

bo.conversations().sync().await.unwrap();
let bo_group = bo.group(alix_group.id()).unwrap();

bo_group.send("bo1".as_bytes().to_vec()).await.unwrap();
alix_group.send("alix1".as_bytes().to_vec()).await.unwrap();

alix_group.add_members(vec![
caro.account_address.clone(),
davon.account_address.clone(),
]).await.unwrap();

bo_group.send("bo2".as_bytes().to_vec()).await.unwrap();
alix_group.send("alix2".as_bytes().to_vec()).await.unwrap();

alix_group.remove_members(vec![
caro.account_address.clone(),
davon.account_address.clone(),
]).await.unwrap();
alix_group.add_members(vec![
eri.account_address.clone(),
frankie.account_address.clone(),
]).await.unwrap();
// Move the group forward by 3 epochs (as Alix's max_past_epochs is
// configured to 3) without Bo syncing
alix_group
.add_members(vec![
caro.account_address.clone(),
davon.account_address.clone(),
])
.await
.unwrap();
alix_group
.remove_members(vec![
caro.account_address.clone(),
davon.account_address.clone(),
])
.await
.unwrap();
alix_group
.add_members(vec![
eri.account_address.clone(),
frankie.account_address.clone(),
])
.await
.unwrap();

// Bo sends messages to Alix while 3 epochs behind
bo_group.send("bo3".as_bytes().to_vec()).await.unwrap();
alix_group.send("alix3".as_bytes().to_vec()).await.unwrap();
bo_group.send("bo4".as_bytes().to_vec()).await.unwrap();
Expand All @@ -2118,8 +2121,8 @@ mod tests {
let bo_messages = bo_group
.find_messages(FfiListMessagesOptions::default())
.unwrap();
assert_eq!(bo_messages.len(), 11);
assert_eq!(alix_messages.len(), 12);
assert_eq!(bo_messages.len(), 9);
assert_eq!(alix_messages.len(), 10);

assert_eq!(bo_messages[0].id, alix_messages[0].id);
}
Expand Down

0 comments on commit fffe60b

Please sign in to comment.