forked from iorust/jsonrpc-lite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.rs
39 lines (36 loc) · 907 Bytes
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
extern crate serde;
#[macro_use]
extern crate serde_json;
extern crate jsonrpc_lite;
use serde_json::{Value, to_value};
use jsonrpc_lite::JsonRpc;
#[test]
fn request() {
let jsonrpc = to_value(JsonRpc::request(0, "test"))
.expect("Unable to turn request into Json Value");
assert_eq!(
jsonrpc,
json!({
"id": 0,
"jsonrpc": "2.0",
"method": "test"
})
);
}
#[test]
fn request_with_params() {
let jsonrpc = to_value(JsonRpc::request_with_params(
String::from("a"),
"test",
vec![Value::Bool(true), Value::Bool(false), Value::Bool(true)],
)).expect("Unable to turn request_with_params into Json Value");
assert_eq!(
jsonrpc,
json!({
"id": "a",
"jsonrpc": "2.0",
"method": "test",
"params": [true, false, true]
})
);
}