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

MinaProtocol / mina / 304

13 Jun 2025 03:53PM UTC coverage: 32.621% (-14.5%) from 47.137%
304

push

buildkite

web-flow
Merge pull request #17410 from MinaProtocol/georgeee/synchronize-develop-compatible

Synchronize `develop` and `compatible` branches

15 of 352 new or added lines in 20 files covered. (4.26%)

18244 existing lines in 391 files now uncovered.

23215 of 71166 relevant lines covered (32.62%)

24792.21 hits per line

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

9.52
/src/lib/disk_cache/lmdb/disk_cache.ml
1
(* Cache proofs using the lmdb *)
2

6✔
3
open Core
4
open Lmdb_storage.Generic
5

6
module Make (Data : Binable.S) = struct
7
  module F (Db : Db) = struct
8
    type holder = (int, Data.t) Db.t
9

10
    let mk_maps { Db.create } =
UNCOV
11
      create Lmdb_storage.Conv.uint32_be
×
UNCOV
12
        (Lmdb_storage.Conv.bin_prot_conv Data.bin_t)
×
13

14
    let config = { default_config with initial_mmap_size = 256 lsl 20 }
15
  end
16

17
  module Rw = Read_write (F)
18

19
  type t = { env : Rw.t; db : Rw.holder; counter : int ref }
20

21
  let initialize path ~logger =
UNCOV
22
    Async.Deferred.Result.map (Disk_cache_utils.initialize_dir path ~logger)
×
23
      ~f:(fun path ->
UNCOV
24
        let env, db = Rw.create path in
×
UNCOV
25
        { env; db; counter = ref 0 } )
×
26

27
  type id = { idx : int }
28

29
  let get ({ env; db; _ } : t) ({ idx } : id) : Data.t =
UNCOV
30
    Rw.get ~env db idx |> Option.value_exn
×
31

32
  let put ({ env; db; counter } : t) (x : Data.t) : id =
UNCOV
33
    let idx = !counter in
×
34
    incr counter ;
UNCOV
35
    let res = { idx } in
×
36
    (* When this reference is GC'd, delete the file. *)
UNCOV
37
    Gc.Expert.add_finalizer_last_exn res (fun () -> Rw.remove ~env db idx) ;
×
UNCOV
38
    Rw.set ~env db idx x ;
×
UNCOV
39
    res
×
40

UNCOV
41
  let iteri ({ env; db; _ } : t) ~f = Rw.iter ~env db ~f
×
42

43
  let count ({ env; db; _ } : t) =
UNCOV
44
    let sum = ref 0 in
×
UNCOV
45
    Rw.iter ~env db ~f:(fun _ _ -> incr sum ; `Continue) ;
×
UNCOV
46
    !sum
×
47

UNCOV
48
  let int_of_id { idx } = idx
×
49
end
50

51
let%test_module "disk_cache lmdb" =
52
  ( module struct
53
    include Disk_cache_test_lib.Make_extended (Make)
54

UNCOV
55
    let%test_unit "remove data on gc" = remove_data_on_gc ()
×
56

57
    let%test_unit "simple read/write (with iteration)" =
UNCOV
58
      simple_write_with_iteration ()
×
59

60
    let%test_unit "initialization special cases" =
UNCOV
61
      initialization_special_cases ()
×
62
  end )
12✔
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