mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 20:09:18 +01:00
cln-grpc: add roundtrip tests for test_getinfo and test_listppers
This commit is contained in:
parent
913f9da5a8
commit
510abb934c
3 changed files with 351 additions and 319 deletions
19
cln-grpc/src/convert.rs
generated
19
cln-grpc/src/convert.rs
generated
|
@ -1705,6 +1705,15 @@ impl From<requests::SetchannelRequest> for pb::SetchannelRequest {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<requests::SigninvoiceRequest> for pb::SigninvoiceRequest {
|
||||
fn from(c: requests::SigninvoiceRequest) -> Self {
|
||||
Self {
|
||||
invstring: c.invstring, // Rule #2 for type string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<requests::SignmessageRequest> for pb::SignmessageRequest {
|
||||
fn from(c: requests::SignmessageRequest) -> Self {
|
||||
|
@ -2521,6 +2530,7 @@ impl From<pb::ListpeersPeers> for responses::ListpeersPeers {
|
|||
Self {
|
||||
id: PublicKey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey
|
||||
connected: c.connected, // Rule #1 for type boolean
|
||||
num_channels: c.num_channels, // Rule #1 for type u32
|
||||
log: Some(c.log.into_iter().map(|s| s.into()).collect()), // Rule #4
|
||||
channels: Some(c.channels.into_iter().map(|s| s.into()).collect()), // Rule #4
|
||||
netaddr: Some(c.netaddr.into_iter().map(|s| s.into()).collect()), // Rule #4
|
||||
|
@ -3407,6 +3417,15 @@ impl From<pb::SetchannelResponse> for responses::SetchannelResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<pb::SigninvoiceResponse> for responses::SigninvoiceResponse {
|
||||
fn from(c: pb::SigninvoiceResponse) -> Self {
|
||||
Self {
|
||||
bolt11: c.bolt11, // Rule #1 for type string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<pb::SignmessageResponse> for responses::SignmessageResponse {
|
||||
fn from(c: pb::SignmessageResponse) -> Self {
|
||||
|
|
|
@ -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); // TODO, still some differences to fix
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -240,8 +245,11 @@ 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();
|
||||
assert_eq!(j, j2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -301,6 +309,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);
|
||||
}
|
||||
|
|
628
contrib/pyln-testing/pyln/testing/node_pb2.py
generated
628
contrib/pyln-testing/pyln/testing/node_pb2.py
generated
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue