Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure message send succeeds even when out of sync #917

Merged
merged 16 commits into from
Jul 25, 2024
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,73 @@ 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() {
let alix = new_test_client().await;
let bo = new_test_client().await;
let caro = new_test_client().await;
let davon = new_test_client().await;
let eri = new_test_client().await;
let frankie = new_test_client().await;

// Create group and send first message
let alix_group = alix
.conversations()
.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();

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();
richardhuaaa marked this conversation as resolved.
Show resolved Hide resolved

bo_group.sync().await.unwrap();
alix_group.sync().await.unwrap();

let alix_messages = alix_group
.find_messages(FfiListMessagesOptions::default())
.unwrap();
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[0].id, alix_messages[0].id);
}

// test is also showing intermittent failures with database locked msg
#[ignore]
Expand Down
Loading