Skip to content

Commit

Permalink
refactor Message to MLSMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
yngrtc committed Aug 30, 2023
1 parent a835c8c commit 3e8b959
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 173 deletions.
19 changes: 11 additions & 8 deletions rmls/src/framing/framing_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use serde::{Deserialize, Serialize};

use crate::error::*;
use crate::group::{group_info::*, proposal::*, Commit, Message};
use crate::framing::MLSMessage;
use crate::group::{group_info::*, proposal::*, Commit};
use crate::serde::{serde_test::load_test_vector, *};
use crate::tree::ratchet::RatchetTree;

Expand Down Expand Up @@ -51,15 +52,17 @@ pub struct MessagesTest {

fn messages_test(tc: MessagesTest) -> Result<()> {
// Welcome
let my_mls_welcome = Message::deserialize_exact(&tc.mls_welcome)?.serialize_detached()?;
let my_mls_welcome = MLSMessage::deserialize_exact(&tc.mls_welcome)?.serialize_detached()?;
assert_eq!(&tc.mls_welcome, my_mls_welcome.as_ref());

// (Verifiable)GroupInfo
let my_mls_group_info = Message::deserialize_exact(&tc.mls_group_info)?.serialize_detached()?;
let my_mls_group_info =
MLSMessage::deserialize_exact(&tc.mls_group_info)?.serialize_detached()?;
assert_eq!(&tc.mls_group_info, my_mls_group_info.as_ref());

// KeyPackage
let my_key_package = Message::deserialize_exact(&tc.mls_key_package)?.serialize_detached()?;
let my_key_package =
MLSMessage::deserialize_exact(&tc.mls_key_package)?.serialize_detached()?;
assert_eq!(&tc.mls_key_package, my_key_package.as_ref());

// RatchetTree
Expand Down Expand Up @@ -104,28 +107,28 @@ fn messages_test(tc: MessagesTest) -> Result<()> {

// MlsPlaintextApplication
let my_public_message_application =
Message::deserialize_exact(&tc.public_message_application)?.serialize_detached()?;
MLSMessage::deserialize_exact(&tc.public_message_application)?.serialize_detached()?;
assert_eq!(
&tc.public_message_application,
my_public_message_application.as_ref()
);

// PublicMessage(Proposal)
let my_public_message_proposal =
Message::deserialize_exact(&tc.public_message_proposal)?.serialize_detached()?;
MLSMessage::deserialize_exact(&tc.public_message_proposal)?.serialize_detached()?;
assert_eq!(
&tc.public_message_proposal,
my_public_message_proposal.as_ref()
);

// PublicMessage(Commit)
let my_public_message_commit =
Message::deserialize_exact(&tc.public_message_commit)?.serialize_detached()?;
MLSMessage::deserialize_exact(&tc.public_message_commit)?.serialize_detached()?;
assert_eq!(&tc.public_message_commit, my_public_message_commit.as_ref());

// PrivateMessage
let my_private_message =
Message::deserialize_exact(&tc.private_message)?.serialize_detached()?;
MLSMessage::deserialize_exact(&tc.private_message)?.serialize_detached()?;
assert_eq!(&tc.private_message, my_private_message.as_ref());

Ok(())
Expand Down
Loading

0 comments on commit 3e8b959

Please sign in to comment.