From 75a49d1ac2afddad05a4d5795d832b47a4e0827d Mon Sep 17 00:00:00 2001 From: phink Date: Thu, 18 Jul 2024 12:12:13 +0200 Subject: [PATCH 1/2] Tezt/Lib: extend Client.t with an optional Dal_node.t --- tezt/lib_tezos/client.ml | 46 +++++++++++++++++++++++++++++++-------- tezt/lib_tezos/client.mli | 5 +++++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/tezt/lib_tezos/client.ml b/tezt/lib_tezos/client.ml index 8f5846cf9c6c..556e5a3793dd 100644 --- a/tezt/lib_tezos/client.ml +++ b/tezt/lib_tezos/client.ml @@ -63,6 +63,7 @@ type t = { mutable additional_bootstraps : Account.key list; mutable mode : mode; runner : Runner.t option; + dal_node : Dal_node.t option; } type stresstest_gas_estimation = { @@ -141,16 +142,26 @@ let address ?(hostname = false) ?from peer = let create_with_mode ?runner ?(path = Uses.path Constant.octez_client) ?(admin_path = Uses.path Constant.octez_admin_client) ?name - ?(color = Log.Color.FG.blue) ?base_dir mode = + ?(color = Log.Color.FG.blue) ?base_dir ?dal_node mode = let name = match name with None -> fresh_name () | Some name -> name in let base_dir = match base_dir with None -> Temp.dir ?runner name | Some dir -> dir in let additional_bootstraps = [] in - {path; admin_path; name; color; base_dir; additional_bootstraps; mode; runner} + { + path; + admin_path; + name; + color; + base_dir; + additional_bootstraps; + mode; + runner; + dal_node; + } let create ?runner ?path ?admin_path ?name ?color ?base_dir ?endpoint - ?media_type () = + ?media_type ?dal_node () = create_with_mode ?runner ?path @@ -158,6 +169,7 @@ let create ?runner ?path ?admin_path ?name ?color ?base_dir ?endpoint ?name ?color ?base_dir + ?dal_node (Client (endpoint, media_type)) let base_dir_arg client = ["--base-dir"; client.base_dir] @@ -763,6 +775,12 @@ let empty_mempool_file ?(filename = "mempool.json") () = write_file mempool ~contents:mempool_str ; mempool +let dal_node_arg dal_node_endpoint client = + match (dal_node_endpoint, client.dal_node) with + | Some endpoint, _ -> ["--dal-node"; endpoint] + | None, Some dal_node -> ["--dal-node"; Dal_node.rpc_endpoint dal_node] + | None, None -> [] + let spawn_bake_for ?endpoint ?protocol ?(keys = [Constant.bootstrap1.alias]) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?(minimal_timestamp = true) ?mempool ?(ignore_node_mempool = false) ?count @@ -788,7 +806,7 @@ let spawn_bake_for ?endpoint ?protocol ?(keys = [Constant.bootstrap1.alias]) @ optional_arg "count" string_of_int count @ (match force with None | Some false -> [] | Some true -> ["--force"]) @ optional_arg "context" Fun.id context_path - @ optional_arg "dal-node" Fun.id dal_node_endpoint + @ dal_node_arg dal_node_endpoint client @ optional_arg "adaptive-issuance-vote" ai_vote_to_string ai_vote @ optional_switch "record_state" state_recorder) @@ -2843,7 +2861,7 @@ let write_sources_file ~min_agreement ~uris client = Lwt_io.fprintf oc "%s" @@ Ezjsonm.value_to_string obj) let init_light ?path ?admin_path ?name ?color ?base_dir ?(min_agreement = 0.66) - ?event_level ?event_sections_levels ?(nodes_args = []) () = + ?event_level ?event_sections_levels ?(nodes_args = []) ?dal_node () = let filter_node_arg = function | Node.Connections _ | Synchronisation_threshold _ -> None | x -> Some x @@ -2865,6 +2883,7 @@ let init_light ?path ?admin_path ?name ?color ?base_dir ?(min_agreement = 0.66) ?name ?color ?base_dir + ?dal_node (Light (min_agreement, List.map (fun n -> Node n) nodes)) in let* () = @@ -2957,7 +2976,7 @@ let get_parameter_file ?additional_bootstrap_accounts ?default_accounts_balance let init_with_node ?path ?admin_path ?name ?node_name ?color ?base_dir ?event_level ?event_sections_levels ?(nodes_args = Node.[Connections 0; Synchronisation_threshold 0]) - ?(keys = Constant.all_secret_keys) ?rpc_external tag () = + ?(keys = Constant.all_secret_keys) ?rpc_external ?dal_node tag () = match tag with | (`Client | `Proxy) as mode -> let* node = @@ -2975,13 +2994,21 @@ let init_with_node ?path ?admin_path ?name ?node_name ?color ?base_dir | `Proxy -> Proxy endpoint in let client = - create_with_mode ?path ?admin_path ?name ?color ?base_dir mode + create_with_mode ?path ?admin_path ?name ?color ?base_dir ?dal_node mode in Account.write keys ~base_dir:client.base_dir ; return (node, client) | `Light -> let* client, node1, _ = - init_light ?path ?admin_path ?name ?color ?base_dir ~nodes_args () + init_light + ?path + ?admin_path + ?name + ?color + ?base_dir + ?dal_node + ~nodes_args + () in return (node1, client) @@ -2989,7 +3016,7 @@ let init_with_protocol ?path ?admin_path ?name ?node_name ?color ?base_dir ?event_level ?event_sections_levels ?nodes_args ?additional_bootstrap_account_count ?additional_revealed_bootstrap_account_count ?default_accounts_balance - ?parameter_file ?timestamp ?keys ?rpc_external tag ~protocol () = + ?parameter_file ?timestamp ?keys ?rpc_external ?dal_node tag ~protocol () = let* node, client = init_with_node ?path @@ -3003,6 +3030,7 @@ let init_with_protocol ?path ?admin_path ?name ?node_name ?color ?base_dir ?nodes_args ?keys ?rpc_external + ?dal_node tag () in diff --git a/tezt/lib_tezos/client.mli b/tezt/lib_tezos/client.mli index ae5d49e22853..41e26bbe7d96 100644 --- a/tezt/lib_tezos/client.mli +++ b/tezt/lib_tezos/client.mli @@ -133,6 +133,7 @@ val create : ?base_dir:string -> ?endpoint:endpoint -> ?media_type:media_type -> + ?dal_node:Dal_node.t -> unit -> t @@ -144,6 +145,7 @@ val create_with_mode : ?name:string -> ?color:Log.Color.t -> ?base_dir:string -> + ?dal_node:Dal_node.t -> mode -> t @@ -2484,6 +2486,7 @@ val init_with_node : ?nodes_args:Node.argument list -> ?keys:Account.key list -> ?rpc_external:bool -> + ?dal_node:Dal_node.t -> [`Client | `Light | `Proxy] -> unit -> (Node.t * t) Lwt.t @@ -2519,6 +2522,7 @@ val init_with_protocol : ?timestamp:timestamp -> ?keys:Account.key list -> ?rpc_external:bool -> + ?dal_node:Dal_node.t -> [`Client | `Light | `Proxy] -> protocol:Protocol.t -> unit -> @@ -2559,6 +2563,7 @@ val init_light : ?event_level:Daemon.Level.default_level -> ?event_sections_levels:(string * Daemon.Level.level) list -> ?nodes_args:Node.argument list -> + ?dal_node:Dal_node.t -> unit -> (t * Node.t * Node.t) Lwt.t -- GitLab From df65b900248d96810bb5644fa72936aa5faee1c8 Mon Sep 17 00:00:00 2001 From: phink Date: Thu, 18 Jul 2024 12:22:18 +0200 Subject: [PATCH 2/2] Tezt/Lib: add getter and setter for the client dal node --- tezt/lib_tezos/client.ml | 4 ++++ tezt/lib_tezos/client.mli | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/tezt/lib_tezos/client.ml b/tezt/lib_tezos/client.ml index 556e5a3793dd..ac150c834ecc 100644 --- a/tezt/lib_tezos/client.ml +++ b/tezt/lib_tezos/client.ml @@ -91,6 +91,10 @@ let get_mode t = t.mode let set_mode mode t = t.mode <- mode +let get_dal_node t = t.dal_node + +let with_dal_node ?dal_node t = {t with dal_node} + let endpoint_wait_for ?where endpoint event filter = match endpoint with | Node node -> Node.wait_for ?where node event filter diff --git a/tezt/lib_tezos/client.mli b/tezt/lib_tezos/client.mli index 41e26bbe7d96..ac38453dfe18 100644 --- a/tezt/lib_tezos/client.mli +++ b/tezt/lib_tezos/client.mli @@ -158,6 +158,13 @@ val get_mode : t -> mode a new client from scratch. *) val set_mode : mode -> t -> unit +(** Get a client's Dal node. *) +val get_dal_node : t -> Dal_node.t option + +(** [with_dal_node t dal_node] returns the client [t] with its + Dal node updated to [dal_node]. *) +val with_dal_node : ?dal_node:Dal_node.t -> t -> t + (** Write the [--sources] file used by the light mode. *) val write_sources_file : min_agreement:float -> uris:string list -> t -> unit Lwt.t -- GitLab