From 34480a85c1b4c192f9748aa2ee4b5e44dc553e6a Mon Sep 17 00:00:00 2001 From: Thomas Letan Date: Fri, 16 Jun 2023 16:21:57 +0200 Subject: [PATCH] Tezt: Support specifying the network address of an Octez node --- tezt/lib_tezos/node.ml | 11 ++++++++--- tezt/lib_tezos/node.mli | 5 +++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tezt/lib_tezos/node.ml b/tezt/lib_tezos/node.ml index af03dcdfc65d..c12bd5183c23 100644 --- a/tezt/lib_tezos/node.ml +++ b/tezt/lib_tezos/node.ml @@ -140,6 +140,7 @@ type 'a known = Unknown | Known of 'a module Parameters = struct type persistent_state = { data_dir : string; + net_addr : string option; mutable net_port : int; advertised_net_port : int option; rpc_host : string; @@ -655,8 +656,9 @@ let wait_for_disconnections node disconnections = waiter let create ?runner ?(path = Constant.tezos_node) ?name ?color ?data_dir - ?event_pipe ?net_port ?advertised_net_port ?(rpc_host = "localhost") - ?rpc_port ?rpc_tls ?(allow_all_rpc = true) arguments = + ?event_pipe ?net_addr ?net_port ?advertised_net_port + ?(rpc_host = "localhost") ?rpc_port ?rpc_tls ?(allow_all_rpc = true) + arguments = let name = match name with None -> fresh_name () | Some name -> name in let data_dir = match data_dir with None -> Temp.dir ?runner name | Some dir -> dir @@ -681,6 +683,7 @@ let create ?runner ?(path = Constant.tezos_node) ?name ?color ?data_dir ?event_pipe { data_dir; + net_addr; net_port; advertised_net_port; rpc_host; @@ -749,7 +752,9 @@ let remove_peers_json_file node = let runlike_command_arguments node command arguments = let net_addr, rpc_addr = match node.persistent_state.runner with - | None -> ("127.0.0.1:", node.persistent_state.rpc_host ^ ":") + | None -> + ( Option.value ~default:"127.0.0.1" node.persistent_state.net_addr ^ ":", + node.persistent_state.rpc_host ^ ":" ) | Some _ -> (* FIXME spawn an ssh tunnel in case of remote host *) ("0.0.0.0:", "0.0.0.0:") diff --git a/tezt/lib_tezos/node.mli b/tezt/lib_tezos/node.mli index 1f508f87cb5b..5f9ae2e0f2d4 100644 --- a/tezt/lib_tezos/node.mli +++ b/tezt/lib_tezos/node.mli @@ -109,6 +109,10 @@ type t whose name is derived from [name]. It will be created as a named pipe so that node events can be received. + Default value for [net_addr] is either [127.0.0.1] if no [runner] is + provided, or a value allowing the local Tezt program to connect to it + if it is. + Default values for [net_port] or [rpc_port] are chosen automatically with values starting from 16384 (configurable with `--starting-port`). They are used by [config_init] @@ -133,6 +137,7 @@ val create : ?color:Log.Color.t -> ?data_dir:string -> ?event_pipe:string -> + ?net_addr:string -> ?net_port:int -> ?advertised_net_port:int -> ?rpc_host:string -> -- GitLab