mirror of
https://github.com/logos-messaging/chat_proto.git
synced 2026-02-21 05:23:10 +00:00
Update tests
This commit is contained in:
parent
2fc0a52b6b
commit
60711bbb01
@ -33,7 +33,6 @@ pub mod logoschat {
|
||||
mod tests {
|
||||
use super::logoschat::{
|
||||
encryption::{encrypted_payload::Encryption, EncryptedPayload, Plaintext},
|
||||
inbox::{inbox_v1_frame::FrameType, InboxV1Frame, Note},
|
||||
invite::InvitePrivateV1,
|
||||
};
|
||||
use bytes::Bytes;
|
||||
@ -62,37 +61,9 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_inbox_frame_roundtrip() {
|
||||
let note = Note {
|
||||
text: "This is a test note".to_string(),
|
||||
};
|
||||
|
||||
let frame = InboxV1Frame {
|
||||
recipient: "alice".to_string(),
|
||||
frame_type: Some(FrameType::Note(note.clone())),
|
||||
};
|
||||
|
||||
let mut buf = Vec::new();
|
||||
frame.encode(&mut buf).expect("Encoding failed");
|
||||
|
||||
let decoded = InboxV1Frame::decode(&buf[..]).expect("Decoding failed");
|
||||
|
||||
match decoded.frame_type {
|
||||
Some(FrameType::Note(n)) => {
|
||||
assert_eq!(n.text, note.text);
|
||||
}
|
||||
_ => panic!("Expected Note variant"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invite_private_roundtrip() {
|
||||
let invite = InvitePrivateV1 {
|
||||
initiator: Bytes::from_static(b"initiator"),
|
||||
initiator_ephemeral: Bytes::from_static(b"ephemeral"),
|
||||
participant: Bytes::from_static(b"participant"),
|
||||
participant_ephemeral_id: 42,
|
||||
discriminator: "test_discriminator".to_string(),
|
||||
initial_message: None, // skipping encrypted payload for simplicity
|
||||
};
|
||||
@ -102,8 +73,6 @@ mod tests {
|
||||
|
||||
let decoded = InvitePrivateV1::decode(&buf[..]).expect("Decoding failed");
|
||||
|
||||
assert_eq!(decoded.initiator, Bytes::from_static(b"initiator"));
|
||||
assert_eq!(decoded.participant_ephemeral_id, 42);
|
||||
assert_eq!(decoded.discriminator, "test_discriminator");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user