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

removed members should not be able to send messages #929

Merged
Merged
Changes from 2 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
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);
tuddman marked this conversation as resolved.
Show resolved Hide resolved
}

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

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