Skip to content

Commit

Permalink
Merge branch 'main' of github.com:xmtp/libxmtp into insipx/web-to-lib…
Browse files Browse the repository at this point in the history
…xmtp
  • Loading branch information
insipx committed Aug 6, 2024
2 parents b992287 + f6c861d commit 272fce2
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 23 deletions.
27 changes: 17 additions & 10 deletions bindings_ffi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 82 additions & 0 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,88 @@ mod tests {
);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
async fn test_can_send_messages_when_epochs_behind() {
let alix = new_test_client().await;
let bo = new_test_client().await;
let caro = new_test_client().await;

let alix_group = alix
.conversations()
.create_group(
vec![caro.account_address.clone()],
FfiCreateGroupOptions::default(),
)
.await
.unwrap();

caro.conversations().sync().await.unwrap();

let caro_group = caro.group(alix_group.id()).unwrap();

alix_group
.send("alix message 1".as_bytes().to_vec())
.await
.unwrap();
caro_group
.send("caro message 1".as_bytes().to_vec())
.await
.unwrap();
alix_group
.add_members(vec![bo.account_address.clone()])
.await
.unwrap();
alix_group
.send("alix message 2".as_bytes().to_vec())
.await
.unwrap();
caro_group
.send("caro message 2".as_bytes().to_vec())
.await
.unwrap();

bo.conversations().sync().await.unwrap();
let bo_group = bo.group(alix_group.id()).unwrap();
bo_group
.send("bo message 1".as_bytes().to_vec())
.await
.unwrap();

bo_group.sync().await.unwrap();
alix_group.sync().await.unwrap();
caro_group.sync().await.unwrap();

let alix_messages = alix_group
.find_messages(FfiListMessagesOptions::default())
.unwrap();
let caro_messages = caro_group
.find_messages(FfiListMessagesOptions::default())
.unwrap();
let bo_messages = bo_group
.find_messages(FfiListMessagesOptions::default())
.unwrap();

let caro_message_2_found_bo = bo_messages
.iter()
.any(|message| message.content == "caro message 2".as_bytes());
assert!(
caro_message_2_found_bo,
"\"caro message 2\" not found in bo_messages"
);

let caro_message_2_found = alix_messages
.iter()
.any(|message| message.content == "caro message 2".as_bytes());
assert!(
caro_message_2_found,
"\"caro message 2\" not found in alix_messages"
);

assert_eq!(alix_messages.len(), 7);
assert_eq!(caro_messages.len(), 6);
assert_eq!(bo_messages.len(), 3);
}

#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
async fn test_can_add_members_when_out_of_sync() {
let alix = new_test_client().await;
Expand Down
32 changes: 20 additions & 12 deletions bindings_node/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion xmtp_mls/src/groups/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl MlsGroup {
intent.id,
group_epoch,
message_epoch,
3, // max_past_epochs, TODO: expose from OpenMLS MlsGroup
1, // max_past_epochs, TODO: expose from OpenMLS MlsGroup
) {
conn.set_group_intent_to_publish(intent.id)?;
return Ok(());
Expand Down

0 comments on commit 272fce2

Please sign in to comment.