Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
codabrink committed Sep 19, 2024
1 parent d98b9ac commit ebe5645
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 23 deletions.
32 changes: 31 additions & 1 deletion xmtp_mls/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -812,16 +812,46 @@ pub fn deserialize_welcome(welcome_bytes: &Vec<u8>) -> Result<Welcome, ClientErr

#[cfg(test)]
mod tests {
use diesel::RunQueryDsl;
use xmtp_cryptography::utils::generate_local_wallet;
use xmtp_id::InboxOwner;

use crate::{
builder::ClientBuilder,
groups::GroupMetadataOptions,
hpke::{decrypt_welcome, encrypt_welcome},
storage::consent_record::{ConsentState, ConsentType},
storage::{
consent_record::{ConsentState, ConsentType},
schema::identity_updates,
},
};

#[tokio::test]
async fn test_group_member_recovery() {
let amal = ClientBuilder::new_test_client(&generate_local_wallet()).await;
let bola_wallet = generate_local_wallet();
// Add two separate installations for Bola
let bola_a = ClientBuilder::new_test_client(&bola_wallet).await;
let bola_b = ClientBuilder::new_test_client(&bola_wallet).await;
let group = amal
.create_group(None, GroupMetadataOptions::default())
.unwrap();

// Add both of Bola's installations to the group
group
.add_members_by_inbox_id(&amal, vec![bola_a.inbox_id(), bola_b.inbox_id()])
.await
.unwrap();

let conn = amal.store().conn().unwrap();
conn.raw_query(|conn| diesel::delete(identity_updates::table).execute(conn))
.unwrap();

let members = group.members(&amal).await.unwrap();
// // The three installations should count as two members
assert_eq!(members.len(), 2);
}

#[tokio::test]
async fn test_mls_error() {
let client = ClientBuilder::new_test_client(&generate_local_wallet()).await;
Expand Down
46 changes: 24 additions & 22 deletions xmtp_mls/src/groups/members.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,35 +122,37 @@ impl MlsGroup {

#[cfg(test)]
mod tests {
// use xmtp_cryptography::utils::generate_local_wallet;

// use crate::builder::ClientBuilder;
use crate::{
builder::ClientBuilder, groups::GroupMetadataOptions, storage::schema::identity_updates,
};
use diesel::RunQueryDsl;
use xmtp_cryptography::utils::generate_local_wallet;

#[tokio::test]
#[ignore]
async fn test_member_list() {
// let amal = ClientBuilder::new_test_client(&generate_local_wallet()).await;
// let bola_wallet = generate_local_wallet();
// // Add two separate installations for Bola
// let bola_a = ClientBuilder::new_test_client(&bola_wallet).await;
// let bola_b = ClientBuilder::new_test_client(&bola_wallet).await;
let amal = ClientBuilder::new_test_client(&generate_local_wallet()).await;
let bola_wallet = generate_local_wallet();
// Add two separate installations for Bola
let bola_a = ClientBuilder::new_test_client(&bola_wallet).await;
let bola_b = ClientBuilder::new_test_client(&bola_wallet).await;
let group = amal
.create_group(None, GroupMetadataOptions::default())
.unwrap();

// let group = amal.create_group(None).unwrap();
// Add both of Bola's installations to the group
// group
// .add_members_by_installation_id(
// vec![
// bola_a.installation_public_key(),
// bola_b.installation_public_key(),
// ],
// &amal,
// )
// .await
// .unwrap();

// let members = group.members().unwrap();
group
.add_members_by_inbox_id(&amal, vec![bola_a.inbox_id(), bola_b.inbox_id()])
.await
.unwrap();

let conn = amal.store().conn().unwrap();
conn.raw_query(|conn| diesel::delete(identity_updates::table).execute(conn))
.unwrap();

let members = group.members(&amal).await.unwrap();
// // The three installations should count as two members
// assert_eq!(members.len(), 2);
assert_eq!(members.len(), 2);

// for member in members {
// if member.account_address.eq(&amal.account_address()) {
Expand Down

0 comments on commit ebe5645

Please sign in to comment.