|
@@ -410,6 +410,7 @@ mod tests {
|
|
OpenOptions::new()
|
|
OpenOptions::new()
|
|
.read(true)
|
|
.read(true)
|
|
.write(true)
|
|
.write(true)
|
|
|
|
+ .truncate(true)
|
|
.create(true)
|
|
.create(true)
|
|
.open(path)
|
|
.open(path)
|
|
.await
|
|
.await
|
|
@@ -490,8 +491,7 @@ mod tests {
|
|
assert_eq!(m1.body, m2.body);
|
|
assert_eq!(m1.body, m2.body);
|
|
}
|
|
}
|
|
|
|
|
|
- #[tokio::test]
|
|
|
|
- async fn serialize_get_message() {
|
|
|
|
|
|
+ async fn serialize_get_message_generic<const P2P: bool>() {
|
|
let m1 = MessageHeader {
|
|
let m1 = MessageHeader {
|
|
sender: "Alice".to_string(),
|
|
sender: "Alice".to_string(),
|
|
group: "group".to_string(),
|
|
group: "group".to_string(),
|
|
@@ -503,16 +503,25 @@ mod tests {
|
|
|
|
|
|
let file_name = "serialize_message_get";
|
|
let file_name = "serialize_message_get";
|
|
let mut f = generate_tmp_file(file_name).await;
|
|
let mut f = generate_tmp_file(file_name).await;
|
|
- serialized.write_all_to(&mut f).await.unwrap();
|
|
|
|
|
|
+ serialized.write_all_to::<P2P, File>(&mut f).await.unwrap();
|
|
|
|
|
|
let mut f = get_tmp_file(file_name).await;
|
|
let mut f = get_tmp_file(file_name).await;
|
|
- let m2 = get_message(&mut f).await.unwrap();
|
|
|
|
|
|
+ let m2 = get_message::<P2P, File>(&mut f).await.unwrap();
|
|
|
|
|
|
assert_eq!(m1, m2);
|
|
assert_eq!(m1, m2);
|
|
}
|
|
}
|
|
|
|
|
|
#[tokio::test]
|
|
#[tokio::test]
|
|
- async fn serialize_get_receipt() {
|
|
|
|
|
|
+ async fn serialize_get_message_client() {
|
|
|
|
+ serialize_get_message_generic::<false>().await;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #[tokio::test]
|
|
|
|
+ async fn serialize_get_message_p2p() {
|
|
|
|
+ serialize_get_message_generic::<true>().await;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async fn serialize_get_receipt_generic<const P2P: bool>() {
|
|
let m1 = MessageHeader {
|
|
let m1 = MessageHeader {
|
|
sender: "Alice".to_string(),
|
|
sender: "Alice".to_string(),
|
|
group: "group".to_string(),
|
|
group: "group".to_string(),
|
|
@@ -524,14 +533,24 @@ mod tests {
|
|
|
|
|
|
let file_name = "serialize_receipt_get";
|
|
let file_name = "serialize_receipt_get";
|
|
let mut f = generate_tmp_file(file_name).await;
|
|
let mut f = generate_tmp_file(file_name).await;
|
|
- serialized.write_all_to(&mut f).await.unwrap();
|
|
|
|
|
|
+ serialized.write_all_to::<P2P, File>(&mut f).await.unwrap();
|
|
|
|
|
|
let mut f = get_tmp_file(file_name).await;
|
|
let mut f = get_tmp_file(file_name).await;
|
|
- let m2 = get_message(&mut f).await.unwrap();
|
|
|
|
|
|
+ let m2 = get_message::<P2P, File>(&mut f).await.unwrap();
|
|
|
|
|
|
assert_eq!(m1, m2);
|
|
assert_eq!(m1, m2);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ #[tokio::test]
|
|
|
|
+ async fn serialize_get_receipt_client() {
|
|
|
|
+ serialize_get_receipt_generic::<false>().await;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #[tokio::test]
|
|
|
|
+ async fn serialize_get_receipt_p2p() {
|
|
|
|
+ serialize_get_receipt_generic::<true>().await;
|
|
|
|
+ }
|
|
|
|
+
|
|
#[tokio::test]
|
|
#[tokio::test]
|
|
async fn serialize_get_handshake() {
|
|
async fn serialize_get_handshake() {
|
|
let h1 = Handshake {
|
|
let h1 = Handshake {
|