浏览代码

Prepare low-level protocol integration test.

父节点
当前提交
e0bc0944c8
共有 5 个文件被更改,包括 67 次插入1 次删除
  1. 18
    0
      Cargo.lock
  2. 1
    1
      Cargo.toml
  3. 29
    0
      src/bin/low_level_integration_test.rs
  4. 4
    0
      src/network/client.rs
  5. 15
    0
      src/network/server.rs

+ 18
- 0
Cargo.lock 查看文件

@@ -16,6 +16,11 @@ dependencies = [
16 16
  "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
17 17
 ]
18 18
 
19
+[[package]]
20
+name = "arc-swap"
21
+version = "0.4.4"
22
+source = "registry+https://github.com/rust-lang/crates.io-index"
23
+
19 24
 [[package]]
20 25
 name = "arrayref"
21 26
 version = "0.3.6"
@@ -797,6 +802,15 @@ dependencies = [
797 802
  "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
798 803
 ]
799 804
 
805
+[[package]]
806
+name = "signal-hook-registry"
807
+version = "1.2.0"
808
+source = "registry+https://github.com/rust-lang/crates.io-index"
809
+dependencies = [
810
+ "arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
811
+ "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
812
+]
813
+
800 814
 [[package]]
801 815
 name = "slab"
802 816
 version = "0.4.2"
@@ -894,8 +908,10 @@ dependencies = [
894 908
  "mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
895 909
  "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
896 910
  "pin-project-lite 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
911
+ "signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
897 912
  "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
898 913
  "tokio-macros 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
914
+ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
899 915
 ]
900 916
 
901 917
 [[package]]
@@ -1054,6 +1070,7 @@ dependencies = [
1054 1070
 [metadata]
1055 1071
 "checksum aho-corasick 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5f56c476256dc249def911d6f7580b5fc7e875895b5d7ee88f5d602208035744"
1056 1072
 "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
1073
+"checksum arc-swap 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d7b8a9123b8027467bce0099fe556c628a53c8d83df0507084c31e9ba2e39aff"
1057 1074
 "checksum arrayref 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
1058 1075
 "checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
1059 1076
 "checksum async-tungstenite 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "37250bc739b253cf2d861047a7bcaad1d46d1d027070b44dbeab9168b40cf407"
@@ -1149,6 +1166,7 @@ dependencies = [
1149 1166
 "checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64"
1150 1167
 "checksum serde_json 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "eab8f15f15d6c41a154c1b128a22f2dfabe350ef53c40953d84e36155c91192b"
1151 1168
 "checksum sha-1 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
1169
+"checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41"
1152 1170
 "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
1153 1171
 "checksum smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc"
1154 1172
 "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"

+ 1
- 1
Cargo.toml 查看文件

@@ -10,7 +10,7 @@ serde = { version = "1.0", features = ["derive"] }
10 10
 serde_json = "1.0"
11 11
 dirs = "2.0"
12 12
 byteorder = "1.3"
13
-tokio = { version = "0.2", features = ["fs", "io-util", "macros", "net", "rt-threaded", "stream", "sync", "tcp", "time"] }
13
+tokio = { version = "0.2", features = ["fs", "io-util", "macros", "net", "rt-threaded", "signal", "stream", "sync", "tcp", "time"] }
14 14
 futures = "0.3.1"
15 15
 async-tungstenite = { version = "0.3", features = ["tokio-runtime"] }
16 16
 env_logger = "0.7"

+ 29
- 0
src/bin/low_level_integration_test.rs 查看文件

@@ -0,0 +1,29 @@
1
+use structopt::StructOpt;
2
+use tokio::signal;
3
+
4
+use twfss::network::client::low_level_integration_test_client;
5
+use twfss::network::server::LowLevelIntegrationTestServer;
6
+
7
+#[derive(Debug, StructOpt)]
8
+#[structopt(about = "Integration tester for the low-level packet protocol.")]
9
+enum Options {
10
+    Server { bind_address: String },
11
+    Client { connect_address: String },
12
+}
13
+
14
+#[tokio::main]
15
+async fn main() {
16
+    match Options::from_args() {
17
+        Options::Server { bind_address } => {
18
+            let server = LowLevelIntegrationTestServer::start(&bind_address).await;
19
+            println!("Listening at {}...", bind_address);
20
+            signal::ctrl_c().await.unwrap();
21
+            println!("Ctrl+C received, stopping...");
22
+            server.stop().await;
23
+        }
24
+        Options::Client { connect_address } => {
25
+            println!("Connecting to {}...", connect_address);
26
+            low_level_integration_test_client(connect_address).await;
27
+        }
28
+    }
29
+}

+ 4
- 0
src/network/client.rs 查看文件

@@ -18,3 +18,7 @@ pub trait RPC: Future {
18 18
 }
19 19
 
20 20
 pub trait ServerEventStream<PacketType>: Stream<Item = PacketType> {}
21
+
22
+pub async fn low_level_integration_test_client(address: String) {
23
+    // TODO
24
+}

+ 15
- 0
src/network/server.rs 查看文件

@@ -21,3 +21,18 @@ trait RPCResponse {
21 21
 
22 22
     fn send(self, packet: &Self::PacketType) -> Result<(), Self::NetworkError>;
23 23
 }
24
+
25
+pub struct LowLevelIntegrationTestServer {
26
+    // TODO
27
+}
28
+
29
+impl LowLevelIntegrationTestServer {
30
+    pub async fn start(bind_address: &str) -> LowLevelIntegrationTestServer {
31
+        // TODO
32
+        LowLevelIntegrationTestServer{}
33
+    }
34
+
35
+    pub async fn stop(self) {
36
+        // TODO
37
+    }
38
+}

正在加载...
取消
保存