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
use std::string::String;
use num_bigint::BigInt;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]
pub struct GetBalanceResponse {
pub jsonrpc: String,
pub id: u32,
#[serde(with = "big_num_manager::serde_format::big_int_hex")]
pub result: BigInt,
}
#[test]
fn test_get_balance_response() {
let resp: GetBalanceResponse = serde_json::from_str(
"
{
\"jsonrpc\": \"2.0\",
\"result\": \"0x1388\",
\"id\": 1
}
",
)
.unwrap();
let expected = GetBalanceResponse {
jsonrpc: "2.0".to_string(),
id: 1,
result: big_num_manager::from_hex_to_big_int("0x1388").unwrap(),
};
assert_eq!(resp, expected);
}