|
@@ -410,6 +410,7 @@ mod tests {
|
|
|
OpenOptions::new()
|
|
|
.read(true)
|
|
|
.write(true)
|
|
|
+ .truncate(true)
|
|
|
.create(true)
|
|
|
.open(path)
|
|
|
.await
|
|
@@ -490,8 +491,7 @@ mod tests {
|
|
|
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 {
|
|
|
sender: "Alice".to_string(),
|
|
|
group: "group".to_string(),
|
|
@@ -503,16 +503,25 @@ mod tests {
|
|
|
|
|
|
let file_name = "serialize_message_get";
|
|
|
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 m2 = get_message(&mut f).await.unwrap();
|
|
|
+ let m2 = get_message::<P2P, File>(&mut f).await.unwrap();
|
|
|
|
|
|
assert_eq!(m1, m2);
|
|
|
}
|
|
|
|
|
|
#[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 {
|
|
|
sender: "Alice".to_string(),
|
|
|
group: "group".to_string(),
|
|
@@ -524,14 +533,24 @@ mod tests {
|
|
|
|
|
|
let file_name = "serialize_receipt_get";
|
|
|
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 m2 = get_message(&mut f).await.unwrap();
|
|
|
+ let m2 = get_message::<P2P, File>(&mut f).await.unwrap();
|
|
|
|
|
|
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]
|
|
|
async fn serialize_get_handshake() {
|
|
|
let h1 = Handshake {
|