Skip to content

Commit

Permalink
cln-grpc: add some roundtrip tests, commented out because failing
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Jan 16, 2023
1 parent 3cd7a2e commit b2cd36b
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions cln-grpc/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,13 @@ fn test_listpeers() {
}
]
});
let u: cln_rpc::model::ListpeersResponse = serde_json::from_value(j).unwrap();
let _: ListpeersResponse = u.into();
let u: cln_rpc::model::ListpeersResponse = serde_json::from_value(j.clone()).unwrap();
let l: ListpeersResponse = u.into();
let u2: cln_rpc::model::ListpeersResponse = l.into();
let j2 = serde_json::to_value(u2).unwrap();
println!("{}", j);
println!("{}", j2);
// assert_eq!(j, j2); // 40 diffs
}

#[test]
Expand All @@ -240,8 +245,13 @@ fn test_getinfo() {
"msatoshi_fees_collected": 0,
"fees_collected_msat": "0msat", "lightning-dir": "/tmp/ltests-20irp76f/test_pay_variants_1/lightning-1/regtest",
"our_features": {"init": "8808226aa2", "node": "80008808226aa2", "channel": "", "invoice": "024200"}});
let u: cln_rpc::model::GetinfoResponse = serde_json::from_value(j).unwrap();
let _g: GetinfoResponse = u.into();
let u: cln_rpc::model::GetinfoResponse = serde_json::from_value(j.clone()).unwrap();
let g: GetinfoResponse = u.into();
let u2: cln_rpc::model::GetinfoResponse = g.into();
let j2 = serde_json::to_value(u2).unwrap();
println!("{}", j);
println!("{}", j2);
// assert_eq!(j, j2); // lighting-dir != lighting_dir
}

#[test]
Expand Down Expand Up @@ -301,6 +311,11 @@ fn test_keysend() {
"status": "complete"
}"#;
let u: cln_rpc::model::KeysendResponse = serde_json::from_str(j).unwrap();
let g: KeysendResponse = u.into();
let g: KeysendResponse = u.clone().into();
println!("{:?}", g);

let v: serde_json::Value = serde_json::to_value(u.clone()).unwrap();
let g: cln_rpc::model::KeysendResponse = u.into();
let v2 = serde_json::to_value(g).unwrap();
assert_eq!(v, v2);
}

0 comments on commit b2cd36b

Please sign in to comment.