Add an integration test for the handshake

This commit is contained in:
Barret Rennie 2019-11-15 16:48:00 -05:00
Родитель fb0966ec71
Коммит fd965997a5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4D71D86C09132D72
4 изменённых файлов: 75 добавлений и 0 удалений

22
Cargo.lock сгенерированный
Просмотреть файл

@ -335,6 +335,16 @@ dependencies = [
"libc",
]
[[package]]
name = "integration-tests"
version = "0.1.0"
dependencies = [
"fxrecorder",
"fxrunner",
"slog",
"tokio",
]
[[package]]
name = "iovec"
version = "0.1.4"
@ -787,6 +797,18 @@ dependencies = [
"mio",
"num_cpus",
"pin-project-lite",
"tokio-macros",
]
[[package]]
name = "tokio-macros"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]

Просмотреть файл

@ -3,4 +3,5 @@ members = [
"fxrecorder",
"fxrunner",
"libfxrecord",
"integration-tests",
]

Просмотреть файл

@ -0,0 +1,20 @@
[package]
name = "integration-tests"
version = "0.1.0"
authors = ["barret Rennie <barret@mozilla.com>"]
edition = "2018"
license = "MPL-2.0"
[[test]]
name = "integration-tests"
path = "src/test.rs"
[dev-dependencies]
slog = "2.5.2"
tokio = { version = "0.2.21", features = ["dns", "macros", "rt-threaded", "tcp"] }
[dev-dependencies.fxrecorder]
path = "../fxrecorder"
[dev-dependencies.fxrunner]
path = "../fxrunner"

Просмотреть файл

@ -0,0 +1,32 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
use libfxrecorder::proto::RecorderProto;
use libfxrunner::proto::RunnerProto;
use slog::Logger;
use tokio::net::{TcpListener, TcpStream};
fn test_logger() -> Logger {
Logger::root(slog::Discard, slog::o! {})
}
#[tokio::test]
async fn test_handshake() {
let mut listener = TcpListener::bind("127.0.0.1:9999").await.unwrap();
let addr = listener.local_addr().unwrap();
tokio::spawn(async move {
let (runner, _) = listener.accept().await.unwrap();
RunnerProto::new(test_logger(), runner)
.handshake_reply()
.await
.unwrap();
});
let recorder = TcpStream::connect(&addr).await.unwrap();
RecorderProto::new(test_logger(), recorder)
.handshake()
.await
.unwrap();
}