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

MinaProtocol / mina / 576

11 Sep 2025 07:14PM UTC coverage: 32.312% (-4.5%) from 36.858%
576

push

buildkite

web-flow
Merge pull request #17777 from MinaProtocol/dkijania/publish_mina_logproc_comp

[CI] publish logproc first

23375 of 72341 relevant lines covered (32.31%)

24759.67 hits per line

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

81.05
/src/test/command_line_tests/command_line_tests.ml
1
open Core
2
open Async
3
open Mina_automation
4

5
module BackgroundMode = struct
6
  type t = Mina_automation_fixture.Daemon.before_bootstrap
7

8
  let test_case (test : t) =
9
    let daemon = Daemon.of_config test.config in
1✔
10
    let%bind () = Daemon.Config.generate_keys test.config in
1✔
11
    let ledger_file = test.config.dirs.conf ^/ "daemon.json" in
1✔
12
    let%bind () =
13
      Mina_automation_fixture.Daemon.generate_random_config daemon ledger_file
1✔
14
    in
15
    let%bind process = Daemon.start daemon in
1✔
16
    let%bind result = Daemon.Client.wait_for_bootstrap process.client () in
1✔
17
    let%bind () =
18
      match result with
19
      | Ok () ->
1✔
20
          Deferred.return ()
1✔
21
      | Error e ->
×
22
          let () = printf "Error:\n%s\n" (Error.to_string_hum e) in
×
23
          let log_file = Daemon.Config.ConfigDirs.mina_log test.config.dirs in
×
24
          let%bind logs = Reader.file_contents log_file in
×
25
          let () = printf "Daemon logs:\n%s\n" logs in
×
26
          Writer.flushed (Lazy.force Writer.stdout)
×
27
    in
28
    let%bind () = Daemon.Client.stop_daemon process.client in
1✔
29
    Deferred.Or_error.return Mina_automation_fixture.Intf.Passed
1✔
30
end
31

32
module DaemonRecover = struct
33
  type t = Mina_automation_fixture.Daemon.before_bootstrap
34

35
  let test_case (test : t) =
36
    let daemon = Daemon.of_config test.config in
1✔
37
    let%bind () = Daemon.Config.generate_keys test.config in
1✔
38
    let ledger_file = test.config.dirs.conf ^/ "daemon.json" in
1✔
39
    let%bind () =
40
      Mina_automation_fixture.Daemon.generate_random_config daemon ledger_file
1✔
41
    in
42
    let%bind process = Daemon.start daemon in
1✔
43
    let%bind.Deferred.Result () =
44
      Daemon.Client.wait_for_bootstrap process.client ()
1✔
45
    in
46
    let%bind.Deferred.Result _ = Daemon.Process.force_kill process in
1✔
47
    let%bind process = Daemon.start daemon in
1✔
48
    let%bind.Deferred.Result () =
49
      Daemon.Client.wait_for_bootstrap process.client ()
1✔
50
    in
51
    let%bind () = Daemon.Client.stop_daemon process.client in
1✔
52
    Deferred.Or_error.return Mina_automation_fixture.Intf.Passed
1✔
53
end
54

55
let contain_log_output output =
56
  String.is_substring ~substring:"{\"timestamp\":" output
5✔
57

58
module LedgerHash = struct
59
  type t = Mina_automation_fixture.Daemon.before_bootstrap
60

61
  let test_case (test : t) =
62
    let daemon = Daemon.of_config test.config in
1✔
63
    let client = Daemon.client daemon in
1✔
64
    let ledger_file = test.config.dirs.conf ^/ "daemon.json" in
1✔
65
    let%bind _ =
66
      Mina_automation_fixture.Daemon.generate_random_accounts daemon ledger_file
1✔
67
    in
68
    let%bind hash = Daemon.Client.ledger_hash client ~ledger_file in
1✔
69
    Deferred.Or_error.return
1✔
70
      ( if contain_log_output hash then
71
        Mina_automation_fixture.Intf.Failed "output contains log"
×
72
      else if not (String.is_prefix ~prefix:"j" hash) then
1✔
73
        Failed "invalid ledger hash prefix"
×
74
      else if Int.( <> ) (String.length hash) 52 then
1✔
75
        Failed
×
76
          (Printf.sprintf "invalid ledger hash length (%d)" (String.length hash))
×
77
      else Passed )
1✔
78
end
79

80
module LedgerCurrency = struct
81
  type t = Mina_automation_fixture.Daemon.before_bootstrap
82

83
  let test_case (test : t) =
84
    let daemon = Daemon.of_config test.config in
1✔
85
    let client = Daemon.client daemon in
1✔
86
    let ledger_file = test.config.dirs.conf ^/ "daemon.json" in
1✔
87
    let%bind accounts =
88
      Mina_automation_fixture.Daemon.generate_random_accounts daemon ledger_file
1✔
89
    in
90
    let total_currency =
1✔
91
      List.map accounts ~f:(fun account ->
1✔
92
          Currency.Balance.to_nanomina_int account.balance )
10✔
93
      |> List.sum (module Int) ~f:Fn.id
94
    in
95
    let%bind output = Daemon.Client.ledger_currency client ~ledger_file in
1✔
96
    let actual = Scanf.sscanf output "MINA : %f" Fn.id in
1✔
97
    let total_currency_float = float_of_int total_currency /. 1000000000.0 in
1✔
98

99
    Deferred.Or_error.return
100
    @@
101
    if contain_log_output output then
102
      Mina_automation_fixture.Intf.Failed "output contains log"
×
103
    else if not Float.(abs (total_currency_float - actual) < 0.001) then
1✔
104
      Failed
×
105
        (Printf.sprintf "invalid mina total count %f vs %f" total_currency_float
×
106
           actual )
107
    else Passed
1✔
108
end
109

110
module AdvancedPrintSignatureKind = struct
111
  type t = Mina_automation_fixture.Daemon.before_bootstrap
112

113
  let test_case (test : t) =
114
    let daemon = Daemon.of_config test.config in
1✔
115
    let client = Daemon.client daemon in
1✔
116
    let%bind output = Daemon.Client.advanced_print_signature_kind client in
1✔
117
    let expected = "testnet" in
1✔
118

119
    Deferred.Or_error.return
120
    @@
121
    if contain_log_output output then
122
      Mina_automation_fixture.Intf.Failed "output contains log"
×
123
    else if not (String.equal expected (String.strip output)) then
1✔
124
      Failed (Printf.sprintf "invalid signature kind %s vs %s" expected output)
×
125
    else Passed
1✔
126
end
127

128
module AdvancedCompileTimeConstants = struct
129
  type t = Mina_automation_fixture.Daemon.before_bootstrap
130

131
  let test_case (test : t) =
132
    let daemon = Daemon.of_config test.config in
1✔
133
    let client = Daemon.client daemon in
1✔
134
    let%bind config_content = Daemon.Client.test_ledger client ~n:10 in
1✔
135
    let config_content =
1✔
136
      Printf.sprintf "{ \"ledger\":{ \"accounts\":%s } }" config_content
137
    in
138
    let temp_file = Filename.temp_file "commandline" "ledger.json" in
1✔
139
    Yojson.Safe.from_string config_content |> Yojson.Safe.to_file temp_file ;
1✔
140
    let%bind output =
141
      Daemon.Client.advanced_compile_time_constants client
1✔
142
        ~config_file:temp_file
143
    in
144

145
    Deferred.Or_error.return
1✔
146
    @@
147
    if contain_log_output output then
148
      Mina_automation_fixture.Intf.Failed "output contains log"
×
149
    else Passed
1✔
150
end
151

152
module AdvancedConstraintSystemDigests = struct
153
  type t = Mina_automation_fixture.Daemon.before_bootstrap
154

155
  let test_case (test : t) =
156
    let daemon = Daemon.of_config test.config in
1✔
157
    let client = Daemon.client daemon in
1✔
158
    let%bind output = Daemon.Client.advanced_constraint_system_digests client in
1✔
159

160
    Deferred.Or_error.return
1✔
161
    @@
162
    if contain_log_output output then
163
      Mina_automation_fixture.Intf.Failed "output contains log"
×
164
    else Passed
1✔
165
end
166

167
let () =
168
  let open Alcotest in
169
  run "Test commadline."
×
170
    [ ( "new-background"
171
      , [ test_case "The mina daemon works in background mode" `Quick
1✔
172
            (Mina_automation_runner.Runner.run_blocking
1✔
173
               ( module Mina_automation_fixture.Daemon
174
                        .Make_FixtureWithoutBootstrap
175
                          (BackgroundMode) ) )
176
        ] )
177
    ; ( "restart"
178
      , [ test_case "The mina daemon recovers from crash" `Quick
1✔
179
            (Mina_automation_runner.Runner.run_blocking
1✔
180
               ( module Mina_automation_fixture.Daemon
181
                        .Make_FixtureWithoutBootstrap
182
                          (DaemonRecover) ) )
183
        ] )
184
    ; ( "ledger-hash"
185
      , [ test_case "The mina ledger hash evaluates correctly" `Quick
1✔
186
            (Mina_automation_runner.Runner.run_blocking
1✔
187
               ( module Mina_automation_fixture.Daemon
188
                        .Make_FixtureWithoutBootstrap
189
                          (LedgerHash) ) )
190
        ] )
191
    ; ( "ledger-currency"
192
      , [ test_case "The mina ledger currency evaluates correctly" `Quick
1✔
193
            (Mina_automation_runner.Runner.run_blocking
1✔
194
               ( module Mina_automation_fixture.Daemon
195
                        .Make_FixtureWithoutBootstrap
196
                          (LedgerCurrency) ) )
197
        ] )
198
    ; ( "advanced-print-signature-kind"
199
      , [ test_case "The mina cli prints correct signature kind" `Quick
1✔
200
            (Mina_automation_runner.Runner.run_blocking
1✔
201
               ( module Mina_automation_fixture.Daemon
202
                        .Make_FixtureWithoutBootstrap
203
                          (AdvancedPrintSignatureKind) ) )
204
        ] )
205
    ; ( "advanced-compile-time-constants"
206
      , [ test_case
1✔
207
            "The mina cli does not print log when printing compile time \
208
             constants"
209
            `Quick
210
            (Mina_automation_runner.Runner.run_blocking
1✔
211
               ( module Mina_automation_fixture.Daemon
212
                        .Make_FixtureWithoutBootstrap
213
                          (AdvancedCompileTimeConstants) ) )
214
        ] )
215
    ; ( "advanced-constraint-system-digests"
216
      , [ test_case
1✔
217
            "The mina cli does not print log when printing constrain system \
218
             digests"
219
            `Quick
220
            (Mina_automation_runner.Runner.run_blocking
1✔
221
               ( module Mina_automation_fixture.Daemon
222
                        .Make_FixtureWithoutBootstrap
223
                          (AdvancedConstraintSystemDigests) ) )
224
        ] )
225
    ]
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