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

MinaProtocol / mina / 2903

15 Nov 2024 01:59PM UTC coverage: 36.723% (-25.0%) from 61.682%
2903

Pull #16342

buildkite

dkijania
Merge branch 'dkijania/remove_publish_job_from_pr_comp' into dkijania/remove_publish_job_from_pr_dev
Pull Request #16342: [DEV] Publish debians only on nightly and stable

15 of 40 new or added lines in 14 files covered. (37.5%)

15175 existing lines in 340 files now uncovered.

24554 of 66863 relevant lines covered (36.72%)

20704.91 hits per line

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

4.35
/src/lib/test_util/test_util.ml
1
open Core_kernel
21✔
2
open Fold_lib
3

4
module Make (Impl : Snarky_backendless.Snark_intf.S) = struct
5
  let triple_string trips =
6
    let to_string b = if b then "1" else "0" in
×
7
    String.concat ~sep:" "
8
      (List.map trips ~f:(fun (b1, b2, b3) ->
×
9
           to_string b1 ^ to_string b2 ^ to_string b3 ) )
×
10

11
  let checked_to_unchecked typ1 typ2 checked input =
UNCOV
12
    let open Impl in
×
13
    let checked_result =
UNCOV
14
      run_and_check
×
UNCOV
15
        (let%bind input = exists typ1 ~compute:(As_prover.return input) in
×
UNCOV
16
         let%map result = checked input in
×
UNCOV
17
         As_prover.read typ2 result )
×
18
      |> Or_error.ok_exn
19
    in
UNCOV
20
    checked_result
×
21

22
  let test_to_triples typ fold var_to_triples input =
23
    let open Impl in
×
24
    let checked =
25
      run_and_check
×
26
        (let%bind input = exists typ ~compute:(As_prover.return input) in
×
27
         let%map result = var_to_triples input in
×
28
         As_prover.all
×
29
           (List.map result
×
30
              ~f:
31
                (As_prover.read
×
32
                   (Typ.tuple3 Boolean.typ Boolean.typ Boolean.typ) ) ) )
×
33
      |> Or_error.ok_exn
34
    in
35
    let unchecked = Fold.to_list (fold input) in
×
36
    if not ([%equal: (bool * bool * bool) list] checked unchecked) then
×
37
      failwithf
×
38
        !"Got %s (%d)\nexpected %s (%d)"
39
        (triple_string checked) (List.length checked) (triple_string unchecked)
×
40
        (List.length unchecked) ()
×
41

UNCOV
42
  let test_equal ?(equal = Poly.( = )) typ1 typ2 checked unchecked input =
×
UNCOV
43
    let checked_result = checked_to_unchecked typ1 typ2 checked input in
×
UNCOV
44
    assert (equal checked_result (unchecked input))
×
45

46
  let arbitrary_string ~len =
UNCOV
47
    String.init (Random.int len) ~f:(fun _ ->
×
UNCOV
48
        Char.of_int_exn (Random.int_incl 0 255) )
×
49

50
  let with_randomness r f =
UNCOV
51
    let s = Caml.Random.get_state () in
×
UNCOV
52
    Random.init r ;
×
UNCOV
53
    try
×
54
      let x = f () in
UNCOV
55
      Caml.Random.set_state s ; x
×
56
    with e -> Caml.Random.set_state s ; raise e
×
57

58
  (** utility function to print digests to put in tests, see `check_serialization' below *)
59
  let print_digest digest = printf "\"" ; printf "%s" digest ; printf "\"\n%!"
×
60

61
  (** use this function to test Bin_prot serialization of types *)
62
  let check_serialization (type t) (module M : Binable.S with type t = t)
63
      (t : t) known_good_digest =
64
    (* serialize value *)
65
    let sz = M.bin_size_t t in
×
66
    let buf = Bin_prot.Common.create_buf sz in
×
67
    ignore (M.bin_write_t buf ~pos:0 t : int) ;
×
68
    let bytes = Bytes.create sz in
69
    Bin_prot.Common.blit_buf_bytes buf bytes ~len:sz ;
×
70
    (* compute MD5 digest of serialization *)
71
    let digest = Md5.digest_bytes bytes |> Md5.to_hex in
×
72
    let result = String.equal digest known_good_digest in
×
73
    if not result then (
×
74
      printf "Expected digest: " ;
75
      print_digest known_good_digest ;
×
76
      printf "Got digest:      " ;
×
77
      print_digest digest ) ;
×
78
    result
×
79
end
80

81
include Make (Snark_params.Tick)
42✔
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