-
Notifications
You must be signed in to change notification settings - Fork 302
/
test_deserialize.rs
35 lines (32 loc) · 1.22 KB
/
test_deserialize.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
use penumbra_proto::core::component::ibc::v1alpha1::Ics20Withdrawal as PbIcs20Withdrawal;
use penumbra_shielded_pool::Ics20Withdrawal;
#[test]
fn test_height_err() {
let data = r#"
{
"amount": {
"lo": "12000000"
},
"denom": {
"denom": "upenumbra"
},
"destinationChainAddress": "xyz",
"returnAddress": {
"inner": "by+DwROtdzWZu+W+gQ+e7pJ328aBf4Lng1dtnnkH971ebSC4O1+fQE+QmMNQ0iEg1/ARaF6yop4BurwW0Z1B7v0/o3AYchf6IEMYBxGyN18="
},
"timeoutHeight": {
"revisionNumber": "5",
"revisionHeight": "3928271"
},
"timeoutTime": "1701471437169",
"sourceChannel": "0"
}
"#;
let withdrawal_proto: PbIcs20Withdrawal = serde_json::from_str(data).unwrap();
let height = withdrawal_proto.clone().timeout_height.unwrap();
assert_eq!(height.revision_height, 5u64); // 5 != 0 ❌
assert_eq!(height.revision_number, 3928271u64); // 3928271 != 0 ❌
let domain_type: Ics20Withdrawal = withdrawal_proto.try_into().unwrap();
assert_eq!(domain_type.timeout_height.revision_number, 5u64);
assert_eq!(domain_type.timeout_height.revision_height, 3928271u64);
}