• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MinaProtocol / mina / 767

04 Nov 2025 01:59PM UTC coverage: 32.374% (-4.5%) from 36.902%
767

push

buildkite

web-flow
Merge pull request #18063 from MinaProtocol/lyh/compat-into-dev-nov4-2025

Merge compatible into develop Nov. 4th 2025

87 of 228 new or added lines in 10 files covered. (38.16%)

3416 existing lines in 136 files now uncovered.

23591 of 72871 relevant lines covered (32.37%)

26590.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

34.85
/src/lib/cli_lib/arg_type.ml
1
open Core
122✔
2
open Signature_lib
3

4
let validate_int16 x =
5
  let max_port = 1 lsl 16 in
102✔
6
  if 0 <= x && x < max_port then Ok x
102✔
7
  else Or_error.errorf "Port not between 0 and %d" max_port
×
8

9
let int16 =
10
  Command.Arg_type.map Command.Param.int
122✔
11
    ~f:(Fn.compose Or_error.ok_exn validate_int16)
122✔
12

13
let pubsub_topic_mode =
14
  let open Gossip_net.Libp2p in
15
  Command.Arg_type.create (fun s ->
122✔
16
      match s with
×
17
      | "ro" ->
×
18
          RO
19
      | "rw" ->
×
20
          RW
21
      | "none" ->
×
22
          N
23
      | _ ->
×
24
          eprintf "Invalid pubsub topic mode: %s" s ;
25
          exit 1 )
×
26

27
let pubsub_topic_mode_to_string mode =
28
  let open Gossip_net.Libp2p in
×
29
  match mode with RO -> "ro" | RW -> "rw" | N -> "none"
×
30

31
let public_key_compressed =
32
  Command.Arg_type.create (fun s ->
122✔
33
      let error_string e =
×
34
        let random = Public_key.compress (Keypair.create ()).public_key in
×
35
        eprintf
×
36
          "Error parsing command line.  Run with -help for usage information.\n\n\
37
           Couldn't read public key\n\
38
          \ %s\n\
39
          \ - here's a sample one: %s\n"
40
          (Error.to_string_hum e)
×
41
          (Public_key.Compressed.to_base58_check random) ;
×
42
        exit 1
×
43
      in
44
      try Public_key.of_base58_check_decompress_exn s
×
45
      with e -> error_string (Error.of_exn e) )
×
46

47
(* Hack to allow us to deprecate a value without needing to add an mli
48
 * just for this. We only want to have one "kind" of public key in the
49
 * public-facing interface if possible *)
50
include (
51
  struct
52
    let public_key =
53
      Command.Arg_type.map public_key_compressed ~f:(fun pk ->
122✔
54
          match Public_key.decompress pk with
×
55
          | None ->
×
56
              failwith "Invalid key"
57
          | Some pk' ->
×
58
              pk' )
59
  end :
60
    sig
61
      val public_key : Public_key.t Command.Arg_type.t
62
        [@@deprecated "Use public_key_compressed in commandline args"]
63
    end )
64

65
let token_id =
66
  Command.Arg_type.map ~f:Mina_base.Token_id.of_string Command.Param.string
122✔
67

68
let receipt_chain_hash =
69
  Command.Arg_type.map Command.Param.string
122✔
70
    ~f:Mina_base.Receipt.Chain_hash.of_base58_check_exn
71

72
let peer : Host_and_port.t Command.Arg_type.t =
73
  Command.Arg_type.create (fun s -> Host_and_port.of_string s)
×
74

75
let uri : Uri.t Command.Arg_type.t = Command.Arg_type.create Uri.of_string
122✔
76

77
let global_slot =
78
  Command.Arg_type.map Command.Param.int
122✔
79
    ~f:Mina_numbers.Global_slot_since_genesis.of_int
80

81
let txn_fee =
82
  Command.Arg_type.map Command.Param.string ~f:Currency.Fee.of_mina_string_exn
122✔
83

84
let txn_amount =
85
  Command.Arg_type.map Command.Param.string
122✔
86
    ~f:Currency.Amount.of_mina_string_exn
87

88
let txn_nonce =
89
  let open Mina_base in
90
  Command.Arg_type.map Command.Param.string ~f:Account.Nonce.of_string
122✔
91

92
let hd_index =
93
  Command.Arg_type.map Command.Param.string ~f:Mina_numbers.Hd_index.of_string
122✔
94

95
let ip_address =
96
  Command.Arg_type.map Command.Param.string ~f:Unix.Inet_addr.of_string
122✔
97

98
let cidr_mask = Command.Arg_type.map Command.Param.string ~f:Unix.Cidr.of_string
122✔
99

100
let log_level =
101
  Command.Arg_type.map Command.Param.string ~f:(fun log_level_str_with_case ->
122✔
102
      let open Logger in
×
103
      let log_level_str = String.lowercase log_level_str_with_case in
104
      match Level.of_string log_level_str with
×
105
      | Error _ ->
×
106
          eprintf "Received unknown log-level %s. Expected one of: %s\n"
107
            log_level_str
108
            ( Level.all |> List.map ~f:Level.show
×
109
            |> List.map ~f:String.lowercase
×
110
            |> String.concat ~sep:", " ) ;
×
111
          exit 14
×
112
      | Ok ll ->
×
113
          ll )
114

115
let user_command =
116
  Command.Arg_type.create (fun s ->
122✔
117
      match Mina_base.Signed_command.of_base64 s with
×
118
      | Ok s ->
×
119
          s
120
      | Error err ->
×
121
          Error.tag err ~tag:"Couldn't decode transaction id" |> Error.raise )
×
122

123
module Work_selection_method = struct
124
  type t = Sequence | Random | Random_offset
125
end
126

127
let work_selection_method_val = function
128
  | "seq" ->
×
129
      Work_selection_method.Sequence
130
  | "rand" ->
×
131
      Random
132
  | "roffset" ->
×
133
      Random_offset
134
  | _ ->
×
135
      failwith "Invalid work selection"
136

137
let work_selection_method =
138
  Command.Arg_type.map Command.Param.string ~f:work_selection_method_val
122✔
139

140
let work_selection_method_to_module :
141
    Work_selection_method.t -> (module Work_selector.Selection_method_intf) =
142
  function
143
  | Sequence ->
×
144
      (module Work_selector.Selection_methods.Sequence)
145
  | Random ->
×
146
      (module Work_selector.Selection_methods.Random)
147
  | Random_offset ->
×
148
      (module Work_selector.Selection_methods.Random_offset)
149

150
module Hardfork_handling = struct
151
  type t = Keep_running | Migrate_exit
152

153
  let of_string = function
NEW
154
    | "keep-running" ->
×
155
        Keep_running
NEW
156
    | "migrate-exit" ->
×
157
        Migrate_exit
UNCOV
158
    | _ ->
×
159
        failwith "Invalid hardfork handling"
160

161
  let arg = Command.Arg_type.map Command.Param.string ~f:of_string
122✔
162
end
244✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc