mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-20 13:54:36 +01:00
msggen: Add stop
method to generators
We'll need this when testing the grpc interface in pyln-testing, otherwise tests just slowly die and wither.
This commit is contained in:
parent
1efa5c37be
commit
18a9eb2feb
9 changed files with 134 additions and 4 deletions
|
@ -53,6 +53,7 @@ service Node {
|
|||
rpc ListPays(ListpaysRequest) returns (ListpaysResponse) {}
|
||||
rpc Ping(PingRequest) returns (PingResponse) {}
|
||||
rpc SignMessage(SignmessageRequest) returns (SignmessageResponse) {}
|
||||
rpc Stop(StopRequest) returns (StopResponse) {}
|
||||
}
|
||||
|
||||
message GetinfoRequest {
|
||||
|
@ -1284,3 +1285,9 @@ message SignmessageResponse {
|
|||
bytes recid = 2;
|
||||
string zbase = 3;
|
||||
}
|
||||
|
||||
message StopRequest {
|
||||
}
|
||||
|
||||
message StopResponse {
|
||||
}
|
||||
|
|
|
@ -963,6 +963,14 @@ impl From<&responses::SignmessageResponse> for pb::SignmessageResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<&responses::StopResponse> for pb::StopResponse {
|
||||
fn from(c: &responses::StopResponse) -> Self {
|
||||
Self {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<&pb::GetinfoRequest> for requests::GetinfoRequest {
|
||||
fn from(c: &pb::GetinfoRequest) -> Self {
|
||||
|
@ -1513,3 +1521,11 @@ impl From<&pb::SignmessageRequest> for requests::SignmessageRequest {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<&pb::StopRequest> for requests::StopRequest {
|
||||
fn from(c: &pb::StopRequest) -> Self {
|
||||
Self {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1466,4 +1466,36 @@ async fn sign_message(
|
|||
|
||||
}
|
||||
|
||||
async fn stop(
|
||||
&self,
|
||||
request: tonic::Request<pb::StopRequest>,
|
||||
) -> Result<tonic::Response<pb::StopResponse>, tonic::Status> {
|
||||
let req = request.into_inner();
|
||||
let req: requests::StopRequest = (&req).into();
|
||||
debug!("Client asked for stop");
|
||||
trace!("stop request: {:?}", req);
|
||||
let mut rpc = ClnRpc::new(&self.rpc_path)
|
||||
.await
|
||||
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
|
||||
let result = rpc.call(Request::Stop(req))
|
||||
.await
|
||||
.map_err(|e| Status::new(
|
||||
Code::Unknown,
|
||||
format!("Error calling method Stop: {:?}", e)))?;
|
||||
match result {
|
||||
Response::Stop(r) => {
|
||||
trace!("stop response: {:?}", r);
|
||||
Ok(tonic::Response::new((&r).into()))
|
||||
},
|
||||
r => Err(Status::new(
|
||||
Code::Internal,
|
||||
format!(
|
||||
"Unexpected result {:?} to method call Stop",
|
||||
r
|
||||
)
|
||||
)),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ pub enum Request {
|
|||
ListPays(requests::ListpaysRequest),
|
||||
Ping(requests::PingRequest),
|
||||
SignMessage(requests::SignmessageRequest),
|
||||
Stop(requests::StopRequest),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
|
@ -112,6 +113,7 @@ pub enum Response {
|
|||
ListPays(responses::ListpaysResponse),
|
||||
Ping(responses::PingResponse),
|
||||
SignMessage(responses::SignmessageResponse),
|
||||
Stop(responses::StopResponse),
|
||||
}
|
||||
|
||||
pub mod requests {
|
||||
|
@ -825,6 +827,10 @@ pub mod requests {
|
|||
pub message: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct StopRequest {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -2745,5 +2751,9 @@ pub mod responses {
|
|||
pub zbase: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct StopResponse {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ def load_jsonrpc_service(schema_dir: str = None):
|
|||
# "waitblockheight",
|
||||
# "ListConfigs",
|
||||
# "check", # No point in mapping this one
|
||||
# "Stop", # Breaks a core assumption (root is an object) can't map unless we change this
|
||||
"Stop",
|
||||
# "notifications", # No point in mapping this
|
||||
# "help",
|
||||
]
|
||||
|
|
|
@ -850,3 +850,8 @@ def signmessage2py(m):
|
|||
"recid": hexlify(m.recid), # PrimitiveField in generate_composite
|
||||
"zbase": m.zbase, # PrimitiveField in generate_composite
|
||||
})
|
||||
|
||||
|
||||
def stop2py(m):
|
||||
return remove_default({
|
||||
})
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -239,6 +239,11 @@ class NodeStub(object):
|
|||
request_serializer=node__pb2.SignmessageRequest.SerializeToString,
|
||||
response_deserializer=node__pb2.SignmessageResponse.FromString,
|
||||
)
|
||||
self.Stop = channel.unary_unary(
|
||||
'/cln.Node/Stop',
|
||||
request_serializer=node__pb2.StopRequest.SerializeToString,
|
||||
response_deserializer=node__pb2.StopResponse.FromString,
|
||||
)
|
||||
|
||||
|
||||
class NodeServicer(object):
|
||||
|
@ -514,6 +519,12 @@ class NodeServicer(object):
|
|||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def Stop(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
|
||||
def add_NodeServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
|
@ -742,6 +753,11 @@ def add_NodeServicer_to_server(servicer, server):
|
|||
request_deserializer=node__pb2.SignmessageRequest.FromString,
|
||||
response_serializer=node__pb2.SignmessageResponse.SerializeToString,
|
||||
),
|
||||
'Stop': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.Stop,
|
||||
request_deserializer=node__pb2.StopRequest.FromString,
|
||||
response_serializer=node__pb2.StopResponse.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'cln.Node', rpc_method_handlers)
|
||||
|
@ -1516,3 +1532,20 @@ class Node(object):
|
|||
node__pb2.SignmessageResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def Stop(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_unary(request, target, '/cln.Node/Stop',
|
||||
node__pb2.StopRequest.SerializeToString,
|
||||
node__pb2.StopResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
|
7
doc/schemas/stop.request.json
Normal file
7
doc/schemas/stop.request.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [],
|
||||
"properties": {}
|
||||
}
|
Loading…
Add table
Reference in a new issue