Skip to content

Commit

Permalink
add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
russelltg committed Mar 23, 2023
1 parent 1236c22 commit a653514
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions srt-tokio/tests/crypto.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use std::time::{Duration, Instant};
use std::{
io,
time::{Duration, Instant},
};

use srt_tokio::SrtSocket;

use assert_matches::assert_matches;
use bytes::Bytes;
use futures::{SinkExt, TryStreamExt};
use log::info;
Expand Down Expand Up @@ -49,5 +53,27 @@ async fn crypto_exchange() {
test_crypto(32).await;
}

// TODO: bad password
#[tokio::test]
async fn bad_password() {
let sender = SrtSocket::builder()
.encryption(16, "password1234")
.listen_on(":2000");

let recvr = SrtSocket::builder()
.encryption(16, "password123")
.call("127.0.0.1:2000", None);

let recv_fut = spawn(async move {
recvr.await.unwrap();
});

let res = sender.await;
assert_matches!(res, Err(e) if e.kind() == io::ErrorKind::ConnectionRefused);

assert_matches!(
tokio::time::timeout(Duration::from_millis(100), recv_fut).await,
Err(_)
);
}

// TODO: mismatch

0 comments on commit a653514

Please sign in to comment.