Skip to content

Commit

Permalink
fix: adds test confirming external client cant join sync group (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuddman authored Jul 29, 2024
1 parent d6c0103 commit 0e12063
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions xmtp_mls/src/groups/message_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ mod tests {
use std::io::{BufRead, BufReader};
use tempfile::NamedTempFile;
use xmtp_cryptography::utils::generate_local_wallet;
use xmtp_id::InboxOwner;

use crate::{assert_ok, builder::ClientBuilder, groups::GroupMetadataOptions};

Expand Down Expand Up @@ -1057,6 +1058,38 @@ mod tests {
assert!(inserted.is_ok());
}

#[tokio::test]
async fn test_externals_cant_join_sync_group() {
let wallet = generate_local_wallet();
let amal = ClientBuilder::new_test_client(&wallet).await;
assert_ok!(amal.allow_history_sync().await);
amal.sync_welcomes().await.expect("sync welcomes");

let external_wallet = generate_local_wallet();
let external_client = ClientBuilder::new_test_client(&external_wallet).await;
assert_ok!(external_client.allow_history_sync().await);
external_client
.sync_welcomes()
.await
.expect("sync welcomes");

let amal_sync_groups = amal
.store()
.conn()
.unwrap()
.find_sync_groups()
.expect("find sync groups");
assert_eq!(amal_sync_groups.len(), 1);

// try to join amal's sync group
let sync_group_id = amal_sync_groups[0].id.clone();
let group = amal.group(sync_group_id).expect("get group");
let result = group
.add_members(&external_client, vec![external_wallet.get_address()])
.await;
assert!(result.is_err());
}

#[test]
fn test_new_pin() {
let pin = new_pin();
Expand Down

0 comments on commit 0e12063

Please sign in to comment.