• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
Info updated!

MinaProtocol / mina / 2863

05 Nov 2024 06:20PM UTC coverage: 30.754% (-16.6%) from 47.311%
2863

push

buildkite

web-flow
Merge pull request #16296 from MinaProtocol/dkijania/more_multi_jobs

more multi jobs in CI

20276 of 65930 relevant lines covered (30.75%)

8631.7 hits per line

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

31.03
/src/lib/sync_status/sync_status.ml
1
open Core_kernel
1✔
2

3
(** Sync_status represent states interacting with peers in the Mina protocol.
4
    When the protocol is starting, the node should be in the CONNECT state
5
    trying to connect to a peer. Once it connects to a peer, the node should be
6
    in the LISTENING state waiting for peers to send a message to them. When
7
    the node receives a constant flow of messages, its state should be SYNCED.
8
    However, when the node is bootstrapping, its state is BOOTSTRAPPING. If it
9
    hasn’t received messages for some time (see [Mina_lib.offline_time]), then
10
    it is OFFLINE.
11
*)
12
let to_string = function
13
  | `Connecting ->
1✔
14
      "Connecting"
15
  | `Listening ->
1✔
16
      "Listening"
17
  | `Offline ->
1✔
18
      "Offline"
19
  | `Bootstrap ->
1✔
20
      "Bootstrap"
21
  | `Synced ->
1✔
22
      "Synced"
23
  | `Catchup ->
1✔
24
      "Catchup"
25

26
let of_string string =
27
  match String.lowercase string with
×
28
  | "connecting" ->
×
29
      Ok `Connecting
30
  | "listening" ->
×
31
      Ok `Listening
32
  | "offline" ->
×
33
      Ok `Offline
34
  | "bootstrap" ->
×
35
      Ok `Bootstrap
36
  | "synced" ->
×
37
      Ok `Synced
38
  | "catchup" ->
×
39
      Ok `Catchup
40
  | status ->
×
41
      Error (Error.createf !"%s is not a valid status" status)
×
42

43
let to_yojson status = `String (to_string status)
×
44

45
let of_yojson : Yojson.Safe.t -> (_, string) Result.t = function
46
  | `String s ->
×
47
      Result.map_error ~f:Error.to_string_hum (of_string s)
×
48
  | _ ->
×
49
      Error "expected string"
50

51
module T = struct
52
  [%%versioned
53
  module Stable = struct
54
    module V1 = struct
55
      type t =
1✔
56
        [ `Connecting | `Listening | `Offline | `Bootstrap | `Synced | `Catchup ]
×
57
      [@@deriving sexp, hash, compare, equal, enumerate]
5✔
58

59
      let to_latest = Fn.id
60

61
      let to_yojson = to_yojson
62

63
      let of_yojson = of_yojson
64

65
      module T = struct
66
        type typ = t [@@deriving sexp, hash, compare, equal, enumerate]
×
67

68
        type t = typ [@@deriving sexp, hash, compare, equal, enumerate]
×
69
      end
70

71
      include Hashable.Make (T)
72
    end
73
  end]
74
end
75

76
include T
77
include Hashable.Make (T)
78

79
let check_conv to_repr of_repr ok_or_fail =
80
  List.for_all
×
81
    [ `Offline; `Bootstrap; `Synced; `Connecting; `Listening; `Catchup ]
82
    ~f:(fun sync_status ->
83
      equal sync_status (of_repr (to_repr sync_status) |> ok_or_fail) )
×
84

85
let%test "of_string (to_string x) == x" =
86
  check_conv to_string of_string Or_error.ok_exn
×
87

88
let%test "of_yojson (to_yojson x) == x" =
89
  check_conv to_yojson of_yojson (function Error e -> failwith e | Ok x -> x)
×
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