diff --git a/plugins/grpc-plugin/src/main.rs b/plugins/grpc-plugin/src/main.rs index 8636fc5ad..369373034 100644 --- a/plugins/grpc-plugin/src/main.rs +++ b/plugins/grpc-plugin/src/main.rs @@ -31,13 +31,17 @@ async fn main() -> Result<()> { let plugin = Builder::new(state.clone(), tokio::io::stdin(), tokio::io::stdout()) .option(options::ConfigOption::new( "grpc-port", - options::Value::Integer(50051), + options::Value::Integer(-1), "Which port should the grpc plugin listen for incoming connections?", )) .start() .await?; let bind_port = match plugin.option("grpc-port") { + Some(options::Value::Integer(-1)) => { + log::info!("`grpc-port` option is not configured, exiting."); + return Ok(()); + } Some(options::Value::Integer(i)) => i, None => return Err(anyhow!("Missing 'grpc-port' option")), Some(o) => return Err(anyhow!("grpc-port is not a valid integer: {:?}", o)), diff --git a/tests/test_cln_rs.py b/tests/test_cln_rs.py index e2b0ef53d..edabc7c58 100644 --- a/tests/test_cln_rs.py +++ b/tests/test_cln_rs.py @@ -1,7 +1,7 @@ from fixtures import * # noqa: F401,F403 from node_pb2_grpc import NodeStub from pathlib import Path -from pyln.testing.utils import env, TEST_NETWORK +from pyln.testing.utils import env, TEST_NETWORK, wait_for from ephemeral_port_reserve import reserve import grpc import node_pb2 as nodepb @@ -69,7 +69,7 @@ def test_plugin_start(node_factory): def test_grpc_connect(node_factory): """Attempts to connect to the grpc interface and call getinfo""" grpc_port = reserve() - bin_path = Path.cwd() / "target" / "debug" / "grpc-plugin" + bin_path = Path.cwd() / "target" / "debug" / "cln-grpc" l1 = node_factory.get_node(options={"plugin": str(bin_path), "grpc-port": str(grpc_port)}) p = Path(l1.daemon.lightning_dir) / TEST_NETWORK @@ -105,7 +105,7 @@ def test_grpc_generate_certificate(node_factory): - If we delete one cert or its key it should get regenerated. """ grpc_port = reserve() - bin_path = Path.cwd() / "target" / "debug" / "grpc-plugin" + bin_path = Path.cwd() / "target" / "debug" / "cln-grpc" l1 = node_factory.get_node(options={ "plugin": str(bin_path), "grpc-port": str(grpc_port), @@ -139,6 +139,18 @@ def test_grpc_generate_certificate(node_factory): assert contents[-1] != files[-1].open().read() +def test_grpc_no_auto_start(node_factory): + """Ensure that we do not start cln-grpc unless a port is configured. + """ + bin_path = Path.cwd() / "target" / "debug" / "cln-grpc" + l1, = node_factory.get_nodes(1, opts={ + "plugin": str(bin_path), + }) + + wait_for(lambda: [p for p in l1.rpc.plugin('list')['plugins'] if 'cln-grpc' in p['name']] == []) + assert l1.daemon.is_in_log(r'plugin-cln-grpc: Killing plugin: exited during normal operation') + + def test_grpc_wrong_auth(node_factory): """An mTLS client certificate should only be usable with its node @@ -146,7 +158,7 @@ def test_grpc_wrong_auth(node_factory): and then we try to cross the wires. """ grpc_port = reserve() - bin_path = Path.cwd() / "target" / "debug" / "grpc-plugin" + bin_path = Path.cwd() / "target" / "debug" / "cln-grpc" l1, l2 = node_factory.get_nodes(2, opts={ "plugin": str(bin_path), "start": False, diff --git a/tools/build-release.sh b/tools/build-release.sh index cb3231b48..bd06d4119 100755 --- a/tools/build-release.sh +++ b/tools/build-release.sh @@ -8,7 +8,7 @@ if [ "$1" = "--inside-docker" ]; then cd /build ./configure make - make install DESTDIR=/"$VER" + make install DESTDIR=/"$VER" RUST_PROFILE=release cd /"$VER" && tar cvfz /release/clightning-"$VER".tar.gz -- * exit 0 fi