Adjust tests for new bincode serialization
@@ -14,9 +14,7 @@ async fn test_single_huge_payload() -> Result<()> {
// The message that should be sent
let payload = "a".repeat(100_000);
let message = create_success_message(payload);
- let original_bytes = serde_json::to_string(&message)
- .expect("Failed to serialize message.")
- .into_bytes();
+ let original_bytes = bincode::serialize(&message).expect("Failed to serialize message.");
// Spawn a sub thread that:
// 1. Accepts a new connection
@@ -27,18 +25,16 @@ async fn test_single_huge_payload() -> Result<()> {
let mut socket = incoming.next().await.unwrap().unwrap();
let message_bytes = receive_bytes(&mut socket).await.unwrap();
- let message = String::from_utf8(message_bytes).unwrap();
- let message: Message = serde_json::from_str(&message).unwrap();
+ let message: Message = bincode::deserialize(&message_bytes).unwrap();
- send_message(&message, &mut socket).await.unwrap();
+ send_message(message, &mut socket).await.unwrap();
});
let mut client = TcpStream::connect(&addr).await?;
// Create a client that sends a message and instantly receives it
- send_message(&message, &mut client).await?;
+ send_message(message, &mut client).await?;
let response_bytes = receive_bytes(&mut client).await?;
- let message = String::from_utf8(response_bytes.clone())?;
- let _message: Message = serde_json::from_str(&message)?;
+ let _message: Message = bincode::deserialize(&response_bytes)?;
assert_eq!(response_bytes, original_bytes);
