Skip to content

Commit

Permalink
pyln-testing: initialize grpc_port value of LightningNode class wit…
Browse files Browse the repository at this point in the history
…h option value before the daemon is configured

Set `grpc_port` default value for pyln-testing
  • Loading branch information
jackstar12 authored and ShahanaFarooqui committed Aug 13, 2024
1 parent eae679a commit cbaacd6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions contrib/pyln-testing/pyln/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,13 +587,14 @@ def __init__(
port=9735,
random_hsm=False,
node_id=0,
grpc_port=None
grpc_port="9736"
):
# We handle our own version of verbose, below.
TailableProc.__init__(self, lightning_dir, verbose=False)
self.executable = 'lightningd'
self.lightning_dir = lightning_dir
self.port = port
self.grpc_port = grpc_port
self.cmd_prefix = []

self.rpcproxy = bitcoindproxy
Expand All @@ -605,6 +606,8 @@ def __init__(
'addr': '127.0.0.1:{}'.format(port),
'allow-deprecated-apis': '{}'.format("true" if DEPRECATED_APIS
else "false"),
'grpc-port': grpc_port,

'network': TEST_NETWORK,
'ignore-fee-limits': 'false',
'bitcoin-rpcuser': BITCOIND_CONFIG['rpcuser'],
Expand All @@ -614,11 +617,6 @@ def __init__(
'bitcoin-datadir': lightning_dir,
}

if grpc_port is not None:
opts['grpc-port'] = grpc_port
else:
opts['disable-plugin'] = 'cln-grpc'

for k, v in opts.items():
self.opts[k] = v

Expand Down Expand Up @@ -765,6 +763,7 @@ def __init__(self, node_id, lightning_dir, bitcoind, executor, valgrind, may_fai
self.allow_warning = allow_warning
self.db = db
self.lightning_dir = Path(lightning_dir)
self.grpc_port = options.get("grpc-port", "9736") if options else "9736"

# Assume successful exit
self.rc = 0
Expand Down Expand Up @@ -839,7 +838,7 @@ def _create_rpc(self, jsonschemas):

def _create_grpc_rpc(self):
from pyln.testing import grpc
self.grpc_port = reserve_unused_port()
self.grpc_port = self.grpc_port or reserve_unused_port()
d = self.lightning_dir / TEST_NETWORK
d.mkdir(parents=True, exist_ok=True)

Expand All @@ -862,7 +861,6 @@ def _create_grpc_rpc(self):

def _create_jsonrpc_rpc(self, jsonschemas):
socket_path = self.lightning_dir / TEST_NETWORK / "lightning-rpc"
self.grpc_port = None

self.rpc = PrettyPrintingLightningRpc(
str(socket_path),
Expand Down

0 comments on commit cbaacd6

Please sign in to comment.