Skip to content

Commit

Permalink
fix another test
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronvoell committed Jan 17, 2025
1 parent a483ec3 commit 7b26c70
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 11 additions & 9 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2253,11 +2253,11 @@ mod tests {
use xmtp_common::tmp_path;
use xmtp_common::{wait_for_eq, wait_for_ok};
use xmtp_content_types::{
attachment::AttachmentCodec, encoded_content_to_bytes, group_updated::GroupUpdatedCodec,
membership_change::GroupMembershipChangeCodec, reaction::ReactionCodec,
read_receipt::ReadReceiptCodec, remote_attachment::RemoteAttachmentCodec,
reply::ReplyCodec, text::TextCodec, transaction_reference::TransactionReferenceCodec,
ContentCodec,
attachment::AttachmentCodec, bytes_to_encoded_content, encoded_content_to_bytes,
group_updated::GroupUpdatedCodec, membership_change::GroupMembershipChangeCodec,
reaction::ReactionCodec, read_receipt::ReadReceiptCodec,
remote_attachment::RemoteAttachmentCodec, reply::ReplyCodec, text::TextCodec,
transaction_reference::TransactionReferenceCodec, ContentCodec,
};
use xmtp_cryptography::{signature::RecoverableSignature, utils::rng};
use xmtp_id::associations::{
Expand Down Expand Up @@ -3062,12 +3062,14 @@ mod tests {
.unwrap();

// Add messages to the group
let text_message_1 = TextCodec::encode("Text message for Group 1".to_string()).unwrap();
group
.send("First message".as_bytes().to_vec())
.send(encoded_content_to_bytes(text_message_1))
.await
.unwrap();
let text_message_2 = TextCodec::encode("Text message for Group 2".to_string()).unwrap();
group
.send("Second message".as_bytes().to_vec())
.send(encoded_content_to_bytes(text_message_2))
.await
.unwrap();

Expand All @@ -3087,8 +3089,8 @@ mod tests {

let last_message = conversations[0].last_message.as_ref().unwrap();
assert_eq!(
last_message.content,
"Second message".as_bytes().to_vec(),
TextCodec::decode(bytes_to_encoded_content(last_message.content.clone())).unwrap(),
"Text message for Group 2".to_string(),
"Last message content should be the most recent"
);
}
Expand Down
4 changes: 4 additions & 0 deletions xmtp_content_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ pub fn encoded_content_to_bytes(content: EncodedContent) -> Vec<u8> {
content.encode(&mut buf).unwrap();
buf
}

pub fn bytes_to_encoded_content(bytes: Vec<u8>) -> EncodedContent {
EncodedContent::decode(&mut bytes.as_slice()).unwrap()
}

0 comments on commit 7b26c70

Please sign in to comment.