Skip to content

Commit

Permalink
adds test around removed member sending msg
Browse files Browse the repository at this point in the history
  • Loading branch information
tuddman committed Jul 30, 2024
1 parent bdeaa75 commit cf674e2
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions xmtp_mls/src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,62 @@ mod tests {
assert!(!bola_group.is_active().unwrap())
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn test_removed_members_cannot_send_message_to_others() {
let amal = ClientBuilder::new_test_client(&generate_local_wallet()).await;
let bola_wallet = &generate_local_wallet();
let bola = ClientBuilder::new_test_client(bola_wallet).await;
let charlie_wallet = &generate_local_wallet();
let charlie = ClientBuilder::new_test_client(charlie_wallet).await;

let group = amal
.create_group(None, GroupMetadataOptions::default())
.unwrap();
group
.add_members(
&amal,
vec![bola_wallet.get_address(), charlie_wallet.get_address()],
)
.await
.unwrap();
assert_eq!(group.members().unwrap().len(), 3);

group
.remove_members(&amal, vec![bola_wallet.get_address()])
.await
.unwrap();
assert_eq!(group.members().unwrap().len(), 2);
assert!(group
.members()
.unwrap()
.iter()
.all(|m| m.inbox_id != bola.inbox_id()));
assert!(group
.members()
.unwrap()
.iter()
.any(|m| m.inbox_id == charlie.inbox_id()));

group.sync(&amal).await.expect("sync failed");

group
.send_message(b"hello", &bola)
.await
.expect_err("expected send_message to fail");

group.sync(&bola).await.expect("sync failed");
group.sync(&amal).await.expect("sync failed");

let amal_messages = group
.find_messages(Some(GroupMessageKind::Application), None, None, None, None)
.unwrap()
.into_iter()
.collect::<Vec<StoredGroupMessage>>();

// FIXME:st this is passing ONLY because the message IS being sent to the group
assert_eq!(amal_messages.len(), 1);
}

// TODO:nm add more tests for filling in missing installations

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
Expand Down

0 comments on commit cf674e2

Please sign in to comment.