Skip to content

Commit

Permalink
proxy: fix tcp_with_no_orig_dst test (#229)
Browse files Browse the repository at this point in the history
Sometimes, the try_read will return a connection error, sometimes it
will just return EOF. Handle both cases.

Closes #226
  • Loading branch information
seanmonstar authored Jan 29, 2018
1 parent 4a76c64 commit 9720a32
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions proxy/tests/transparency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ fn inbound_tcp() {
fn tcp_with_no_orig_dst() {
let _ = env_logger::init();

let srv = server::tcp().run();
let srv = server::tcp()
.accept(move |_| "don't read me")
.run();
let ctrl = controller::new().run();
let proxy = proxy::new()
.controller(ctrl)
Expand All @@ -240,7 +242,11 @@ fn tcp_with_no_orig_dst() {
let tcp_client = client.connect();
tcp_client.write("custom tcp hello");

assert!(tcp_client.try_read().is_err());
let read = tcp_client
.try_read()
// This read might be an error, or an empty vec
.unwrap_or_else(|_| Vec::new());
assert_eq!(read, b"");
}

#[test]
Expand Down

0 comments on commit 9720a32

Please sign in to comment.