Skip to content

Commit

Permalink
Reorder test for clarity, fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhuaaa committed Jul 24, 2024
1 parent e36b81a commit 9d7df2a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
68 changes: 34 additions & 34 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2157,7 +2157,7 @@ mod tests {
}

#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
async fn test_can_add_members_when_out_of_sync() {
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 Down Expand Up @@ -2197,27 +2197,39 @@ mod tests {
.await
.unwrap();
alix_group
.add_members(vec![eri.account_address.clone()])
.add_members(vec![
eri.account_address.clone(),
frankie.account_address.clone(),
])
.await
.unwrap();

// Bo adds a member while 3 epochs behind
bo_group
.add_members(vec![frankie.account_address.clone()])
.await
// 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();
bo_group.send("bo5".as_bytes().to_vec()).await.unwrap();

alix_group.sync().await.unwrap();
let alix_messages = alix_group
.find_messages(FfiListMessagesOptions::default())
.unwrap();

bo_group.sync().await.unwrap();
let bo_members = bo_group.list_members().unwrap();
assert_eq!(bo_members.len(), 4);
let bo_messages = bo_group
.find_messages(FfiListMessagesOptions::default())
.unwrap();
assert_eq!(bo_messages.len(), 9);
assert_eq!(alix_messages.len(), 10);

alix_group.sync().await.unwrap();
let alix_members = alix_group.list_members().unwrap();
assert_eq!(alix_members.len(), 4);
assert_eq!(
bo_messages[bo_messages.len() - 1].id,
alix_messages[alix_messages.len() - 1].id
);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
async fn test_can_send_message_when_out_of_sync() {
async fn test_can_add_members_when_out_of_sync() {
let alix = new_test_client().await;
let bo = new_test_client().await;
let caro = new_test_client().await;
Expand Down Expand Up @@ -2257,35 +2269,23 @@ mod tests {
.await
.unwrap();
alix_group
.add_members(vec![
eri.account_address.clone(),
frankie.account_address.clone(),
])
.add_members(vec![eri.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();
bo_group.send("bo5".as_bytes().to_vec()).await.unwrap();

alix_group.sync().await.unwrap();
let alix_messages = alix_group
.find_messages(FfiListMessagesOptions::default())
// Bo adds a member while 3 epochs behind
bo_group
.add_members(vec![frankie.account_address.clone()])
.await
.unwrap();

bo_group.sync().await.unwrap();
let bo_messages = bo_group
.find_messages(FfiListMessagesOptions::default())
.unwrap();
assert_eq!(bo_messages.len(), 9);
assert_eq!(alix_messages.len(), 10);
let bo_members = bo_group.list_members().unwrap();
assert_eq!(bo_members.len(), 4);

assert_eq!(
bo_messages[bo_messages.len() - 1].id,
alix_messages[alix_messages.len() - 1].id
);
alix_group.sync().await.unwrap();
let alix_members = alix_group.list_members().unwrap();
assert_eq!(alix_members.len(), 4);
}

// test is also showing intermittent failures with database locked msg
Expand Down
2 changes: 1 addition & 1 deletion xmtp_mls/src/groups/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl MlsGroup {
);
return false;
}
return true;
true
}

#[allow(clippy::too_many_arguments)]
Expand Down

0 comments on commit 9d7df2a

Please sign in to comment.