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

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

51.72
/src/lib/bounded_types/bounded_types.ml
1
open Core_kernel
13✔
2
open Core_kernel.Hash.Builtin
3

4
module N16 = struct
5
  let max_array_len = 16
6
end
7

8
module N4000 = struct
9
  let max_array_len = 4000
10
end
11

12
module ArrayN (N : sig
13
  val max_array_len : int
14
end) =
15
struct
16
  module Stable = struct
17
    module V1 = struct
18
      type 'a t = 'a array [@@deriving sexp, yojson, bin_io]
6✔
19

20
      let __versioned__ = ()
21

22
      let hash_fold_t = hash_fold_array_frozen
23

24
      [%%define_locally Core_kernel.Array.(compare, equal)]
25

26
      let to_latest s = s
×
27

28
      let bin_shape_t bin_shape_elt =
29
        Bin_prot.Shape.basetype
118✔
30
          (Bin_prot.Shape.Uuid.of_string "Bounded_types.Array.t")
118✔
31
          [ bin_shape_elt ]
32

33
      let bin_write_t bin_write_el buf ~pos a =
34
        if Array.length a > N.max_array_len then
1,132✔
35
          failwithf "Exceeded array maximum size (max %d < got %d)"
×
36
            N.max_array_len (Array.length a) () ;
×
37
        bin_write_array bin_write_el buf ~pos a
1,132✔
38

39
      let bin_read_t bin_read_el buf ~pos_ref =
40
        let pos = !pos_ref in
174✔
41
        let len = (Bin_prot.Read.bin_read_nat0 buf ~pos_ref :> int) in
174✔
42
        if len > N.max_array_len then
43
          Bin_prot.Common.raise_read_error
×
44
            Bin_prot.Common.ReadError.Array_too_long !pos_ref
45
        else (
174✔
46
          pos_ref := pos ;
47
          bin_read_array bin_read_el buf ~pos_ref )
48
    end
49
  end
50

51
  type 'a t = 'a Stable.V1.t
52

53
  [%%define_locally
54
  Stable.V1.
55
    (compare, equal, hash_fold_t, sexp_of_t, t_of_sexp, to_yojson, of_yojson)]
56
end
57

58
module String = struct
59
  let max_string_len = 100_000_000
60

61
  module Stable = struct
62
    module V1 = struct
63
      type t = string [@@deriving sexp, yojson, bin_io]
7✔
64

65
      let __versioned__ = ()
66

67
      let to_latest s = s
×
68

69
      [%%define_locally Core_kernel.String.(compare, equal)]
70

71
      let hash = hash_string
72

73
      let hash_fold_t = hash_fold_string
74

75
      let bin_shape_t =
76
        Bin_prot.Shape.basetype
13✔
77
          (Bin_prot.Shape.Uuid.of_string "Bounded_types.String.t")
13✔
78
          []
79

80
      let bin_write_t buf ~pos s =
81
        if String.length s > max_string_len then
150,760✔
82
          failwith "Exceeded string maximum size" ;
×
83
        bin_write_string buf ~pos s
150,760✔
84

85
      let bin_read_t buf ~pos_ref =
86
        let pos = !pos_ref in
×
87
        let len = (Bin_prot.Read.bin_read_nat0 buf ~pos_ref :> int) in
×
88
        if len > max_string_len then
89
          Bin_prot.Common.raise_read_error
×
90
            Bin_prot.Common.ReadError.Array_too_long !pos_ref
91
        else (
×
92
          pos_ref := pos ;
93
          bin_read_string buf ~pos_ref )
94
    end
95
  end
96

97
  type t = Stable.V1.t
98

99
  [%%define_locally
100
  Stable.V1.
101
    ( compare
102
    , equal
103
    , hash
104
    , hash_fold_t
105
    , sexp_of_t
106
    , t_of_sexp
107
    , to_yojson
108
    , of_yojson )]
109

110
  module Tagged = struct
111
    module Stable = struct
112
      module V1 = struct
113
        include Stable.V1
114

115
        (* because this is replacing a primitive,
116
           there is no actual version tag handling
117
           needed (and in fact, that will make a
118
           test in transaction fail *)
119
        module With_all_version_tags = Stable.V1
120
      end
121
    end
122

123
    include Stable.V1
124
  end
125

126
  module Of_stringable (M : Stringable.S) =
127
  Bin_prot.Utils.Make_binable_without_uuid (struct
128
    module Binable = Stable.V1
129

130
    type t = M.t
131

132
    let to_binable = M.to_string
133

134
    (* Wrap exception for improved diagnostics. *)
135
    exception Of_binable of string * exn [@@deriving sexp]
136

137
    let of_binable s = try M.of_string s with x -> raise (Of_binable (s, x))
×
138
  end)
139
end
140

141
module Wrapped_error = struct
142
  module Stable = struct
143
    module V1 = struct
144
      type t = Core_kernel.Error.Stable.V2.t [@@deriving sexp]
×
145

146
      let __versioned__ = ()
147

148
      let to_latest = Core_kernel.Fn.id
149

150
      include String.Of_stringable (struct
151
        type nonrec t = t
152

153
        let to_string (s : t) =
154
          Core_kernel.Error.sexp_of_t s |> Core_kernel.Sexp.to_string_mach
×
155

156
        let of_string s =
157
          Core_kernel.Error.t_of_sexp (Core_kernel.Sexp.of_string s)
×
158
      end)
159
    end
160
  end
161

162
  type t = Stable.V1.t
163
end
164

165
module ArrayN16 = ArrayN (N16)
166
module ArrayN4000 = ArrayN (N4000)
26✔
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