Use into_split() in test

This commit is contained in:
Matéo Duparc 2021-06-18 19:33:54 +02:00
parent 904e53f6de
commit e2f38468c7
Signed by: hardcoresushi
GPG Key ID: 007F84120107191E
2 changed files with 5 additions and 3 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "async-psec"
version = "0.3.1"
version = "0.3.2"
authors = ["Hardcore Sushi <hardcore.sushi@disroot.org>"]
edition = "2018"
description = "Asynchronous PSEC implementation"

View File

@ -23,9 +23,11 @@ async fn tokio_main() {
session.encrypt_and_send(b"Hello I'm Bob", true).await.unwrap();
assert_eq!(session.receive_and_decrypt().await.unwrap(), b"Hello I'm Alice");
session.encrypt_and_send("!".repeat(997).as_bytes(), true).await.unwrap();
let (mut reader, mut writer) = session.into_split().unwrap();
assert_eq!(session.receive_and_decrypt().await, Err(PsecError::TransmissionCorrupted));
writer.encrypt_and_send("!".repeat(997).as_bytes(), true).await.unwrap();
assert_eq!(reader.receive_and_decrypt().await, Err(PsecError::TransmissionCorrupted));
});
let stream = TcpStream::connect(format!("127.0.0.1:{}", bind_addr.port())).await.unwrap();