mirror of
https://github.com/OMGeeky/tarpc.git
synced 2025-12-29 15:49:52 +01:00
Add a second rpc to test service.
To better exercise the serialization parts -- namely, the enum tags.
This commit is contained in:
@@ -471,6 +471,7 @@ mod functional_test {
|
||||
|
||||
service! {
|
||||
rpc add(x: i32, y: i32) -> i32;
|
||||
rpc hey(name: String) -> String;
|
||||
}
|
||||
|
||||
struct Server;
|
||||
@@ -479,6 +480,9 @@ mod functional_test {
|
||||
fn add(&self, x: i32, y: i32) -> i32 {
|
||||
x + y
|
||||
}
|
||||
fn hey(&self, name: String) -> String {
|
||||
format!("Hey, {}.", name)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -487,6 +491,7 @@ mod functional_test {
|
||||
let handle = serve("localhost:0", Server, test_timeout()).unwrap();
|
||||
let client = Client::new(handle.local_addr(), None).unwrap();
|
||||
assert_eq!(3, client.add(1, 2).unwrap());
|
||||
assert_eq!("Hey, Tim.", client.hey("Tim".into()).unwrap());
|
||||
drop(client);
|
||||
handle.shutdown();
|
||||
}
|
||||
@@ -497,6 +502,7 @@ mod functional_test {
|
||||
let handle = serve("localhost:0", Server, test_timeout()).unwrap();
|
||||
let client = AsyncClient::new(handle.local_addr(), None).unwrap();
|
||||
assert_eq!(3, client.add(1, 2).get().unwrap());
|
||||
assert_eq!("Hey, Adam.", client.hey("Adam".into()).get().unwrap());
|
||||
drop(client);
|
||||
handle.shutdown();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user