Skip to content

Commit

Permalink
reproduced it in a test
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Jul 22, 2024
1 parent d1cd793 commit ccf4e65
Showing 1 changed file with 67 additions and 0 deletions.
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();

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

0 comments on commit ccf4e65

Please sign in to comment.