Skip to content

Commit

Permalink
pytest: Add a test for the grpc plugin
Browse files Browse the repository at this point in the history
Currently still unencrypted, but will get its mTLS authentication in
the next commits.
  • Loading branch information
cdecker committed Jan 21, 2022
1 parent 92fc01a commit 687693d
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions tests/test_cln_rs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from fixtures import * # noqa: F401,F403
from pathlib import Path
from pyln.testing.utils import env, TEST_NETWORK
import subprocess
import os
import pytest
import subprocess
from pathlib import Path

import grpc
import node_pb2 as nodepb
import pytest
from fixtures import TEST_NETWORK
from fixtures import * # noqa: F401,F403
from node_pb2_grpc import NodeStub
from pyln.testing.utils import env

# Skip the entire module if we don't have Rust.
pytestmark = pytest.mark.skipif(
Expand All @@ -21,3 +25,17 @@ def test_rpc_client(node_factory):
rpc_path = Path(l1.daemon.lightning_dir) / TEST_NETWORK / "lightning-rpc"
out = subprocess.check_output([bin_path, rpc_path], stderr=subprocess.STDOUT)
assert(b'0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518' in out)


def test_grpc_connect(node_factory):
"""Attempts to connect to the grpc interface and call getinfo"""
bin_path = Path.cwd() / "target" / "debug" / "grpc-plugin"
node_factory.get_node(options={"plugin": str(bin_path)})
channel = grpc.insecure_channel("localhost:50051")
stub = NodeStub(channel)

response = stub.Getinfo(nodepb.GetinfoRequest())
print(response)

response = stub.ListFunds(nodepb.ListfundsRequest())
print(response)

0 comments on commit 687693d

Please sign in to comment.