Skip to content

Commit

Permalink
The first message sent gets lost when Epochs behind (#935)
Browse files Browse the repository at this point in the history
* lock stuff

* min reproduction test

* set max epochs behind to 1 for now

---------

Co-authored-by: cameronvoell <[email protected]>
  • Loading branch information
nplasterer and cameronvoell authored Aug 5, 2024
1 parent 4296e9c commit f6c861d
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 11 deletions.
8 changes: 4 additions & 4 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
13 changes: 7 additions & 6 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 f6c861d

Please sign in to comment.