Skip to content

Commit

Permalink
simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronvoell committed Dec 3, 2024
1 parent 863a997 commit 5305d97
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions bindings_ffi/src/mls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,7 @@ pub fn decode_reaction(bytes: Vec<u8>) -> Result<FfiReaction, GenericError> {
.map_err(|e| GenericError::Generic { err: e.to_string() })
}

#[derive(uniffi::Enum, Clone, Default)]
#[derive(uniffi::Enum, Clone, Default, PartialEq, Debug)]
pub enum FfiReactionAction {
Unknown,
#[default]
Expand All @@ -1779,7 +1779,7 @@ impl From<FfiReactionAction> for i32 {
}
}

#[derive(uniffi::Enum, Clone, Default)]
#[derive(uniffi::Enum, Clone, Default, PartialEq, Debug)]
pub enum FfiReactionSchema {
Unknown,
#[default]
Expand Down Expand Up @@ -4589,15 +4589,8 @@ mod tests {
content: "👍".to_string(),
schema: FfiReactionSchema::Unicode,
};

let reaction_sent: Reaction = ffi_reaction.into();
let mut buf = Vec::new();
ReactionCodec::encode(reaction_sent)
.unwrap()
.encode(&mut buf)
.unwrap();

bo_conversation.send(buf).await.unwrap();
let bytes_to_send = encode_reaction(ffi_reaction).unwrap();
bo_conversation.send(bytes_to_send).await.unwrap();

// Have Alix sync to get the reaction
alix_conversation.sync().await.unwrap();
Expand All @@ -4611,17 +4604,15 @@ mod tests {
assert_eq!(messages.len(), 3);
let received_reaction = &messages[2];
let message_content = received_reaction.content.clone();
let slice: &[u8] = message_content.as_slice();
let encoded_content = EncodedContent::decode(slice).unwrap();
let reaction = Reaction::decode(encoded_content.content.as_slice()).unwrap();
let reaction = decode_reaction(message_content).unwrap();
assert_eq!(reaction.content, "👍");
assert_eq!(reaction.action, ReactionAction::ActionAdded as i32);
assert_eq!(reaction.action, FfiReactionAction::Added);
assert_eq!(reaction.reference_inbox_id, alix.inbox_id());
assert_eq!(
reaction.reference,
hex::encode(message_to_react_to.id.clone())
);
assert_eq!(reaction.schema, ReactionSchema::SchemaUnicode as i32);
assert_eq!(reaction.schema, FfiReactionSchema::Unicode);

// Test find_messages_with_reactions query
let messages_with_reactions: Vec<FfiMessageWithReactions> = alix_conversation
Expand Down

0 comments on commit 5305d97

Please sign in to comment.