• 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

3.77
/src/lib/network_pool/test.ml
1
open Async_kernel
4✔
2
open Core_kernel
3
open Pipe_lib
4
open Network_peer
5

6
let%test_module "network pool test" =
7
  ( module struct
8
    let trust_system = Mocks.trust_system
9

UNCOV
10
    let logger = Logger.null ()
×
11

UNCOV
12
    let precomputed_values = Lazy.force Precomputed_values.for_unit_tests
×
13

14
    let constraint_constants = precomputed_values.constraint_constants
15

16
    let consensus_constants = precomputed_values.consensus_constants
17

18
    let proof_level = precomputed_values.proof_level
19

20
    let time_controller = Block_time.Controller.basic ~logger
21

22
    let block_window_duration =
NEW
23
      Float.of_int
×
24
        Genesis_constants.For_unit_tests.Constraint_constants.t
25
          .block_window_duration_ms
NEW
26
      |> Time.Span.of_ms
×
27

28
    let verifier =
UNCOV
29
      Async.Thread_safe.block_on_async_exn (fun () ->
×
UNCOV
30
          Verifier.For_tests.default ~constraint_constants ~logger ~proof_level
×
31
            () )
32

33
    module Mock_snark_pool =
34
      Snark_pool.Make (Mocks.Base_ledger) (Mocks.Staged_ledger)
35
        (Mocks.Transition_frontier)
36

37
    let config =
38
      Mock_snark_pool.Resource_pool.make_config ~verifier ~trust_system
39
        ~disk_location:"/tmp/snark-pool"
40

41
    let%test_unit "Work that gets fed into apply_and_broadcast will be \
42
                   received in the pool's reader" =
UNCOV
43
      let tf = Mocks.Transition_frontier.create [] in
×
UNCOV
44
      let frontier_broadcast_pipe_r, _ = Broadcast_pipe.create (Some tf) in
×
UNCOV
45
      let work =
×
46
        `One
UNCOV
47
          (Quickcheck.random_value ~seed:(`Deterministic "network_pool_test")
×
48
             Transaction_snark.Statement.gen )
49
      in
50
      let priced_proof =
51
        { Priced_proof.proof =
UNCOV
52
            One_or_two.map ~f:Ledger_proof.For_tests.mk_dummy_proof work
×
53
        ; fee =
54
            { fee = Currency.Fee.zero
55
            ; prover = Signature_lib.Public_key.Compressed.empty
56
            }
57
        }
58
      in
59
      Async.Thread_safe.block_on_async_exn (fun () ->
UNCOV
60
          let network_pool, _, _ =
×
61
            Mock_snark_pool.create ~config ~logger ~constraint_constants
62
              ~consensus_constants ~time_controller
63
              ~frontier_broadcast_pipe:frontier_broadcast_pipe_r
UNCOV
64
              ~log_gossip_heard:false ~on_remote_push:(Fn.const Deferred.unit)
×
65
              ~block_window_duration
66
          in
67
          let%bind () =
UNCOV
68
            Mocks.Transition_frontier.refer_statements tf [ work ]
×
69
          in
UNCOV
70
          let command =
×
71
            Mock_snark_pool.Resource_pool.Diff.Add_solved_work
72
              (work, priced_proof)
73
          in
74
          Mock_snark_pool.apply_and_broadcast network_pool
UNCOV
75
            (Envelope.Incoming.local command)
×
UNCOV
76
            (Mock_snark_pool.Broadcast_callback.Local (Fn.const ())) ;
×
77
          let%map _ =
UNCOV
78
            Linear_pipe.read (Mock_snark_pool.broadcasts network_pool)
×
79
          in
UNCOV
80
          let pool = Mock_snark_pool.resource_pool network_pool in
×
UNCOV
81
          match Mock_snark_pool.Resource_pool.request_proof pool work with
×
UNCOV
82
          | Some { proof; fee = _ } ->
×
UNCOV
83
              assert (
×
84
                [%equal: Ledger_proof.t One_or_two.t] proof priced_proof.proof )
×
85
          | None ->
×
86
              failwith "There should have been a proof here" )
87

88
    let%test_unit "when creating a network, the incoming diffs and local diffs \
89
                   in the reader pipes will automatically get process" =
UNCOV
90
      let work_count = 10 in
×
91
      let works =
UNCOV
92
        Quickcheck.random_sequence ~seed:(`Deterministic "works")
×
93
          Transaction_snark.Statement.gen
UNCOV
94
        |> Fn.flip Sequence.take work_count
×
UNCOV
95
        |> Sequence.map ~f:(fun x -> `One x)
×
96
        |> Sequence.to_list
97
      in
UNCOV
98
      let per_reader = work_count / 2 in
×
99
      let create_work work =
UNCOV
100
        Mock_snark_pool.Resource_pool.Diff.Add_solved_work
×
101
          ( work
102
          , Priced_proof.
103
              { proof =
UNCOV
104
                  One_or_two.map ~f:Ledger_proof.For_tests.mk_dummy_proof work
×
105
              ; fee =
106
                  { fee = Currency.Fee.zero
107
                  ; prover = Signature_lib.Public_key.Compressed.empty
108
                  }
109
              } )
110
      in
111
      let verify_unsolved_work () =
UNCOV
112
        let%bind () = Async.Scheduler.yield_until_no_jobs_remain () in
×
UNCOV
113
        let tf = Mocks.Transition_frontier.create [] in
×
UNCOV
114
        let frontier_broadcast_pipe_r, _ = Broadcast_pipe.create (Some tf) in
×
UNCOV
115
        let network_pool, remote_sink, local_sink =
×
116
          Mock_snark_pool.create ~config ~logger ~constraint_constants
117
            ~consensus_constants ~time_controller
118
            ~frontier_broadcast_pipe:frontier_broadcast_pipe_r
UNCOV
119
            ~log_gossip_heard:false ~on_remote_push:(Fn.const Deferred.unit)
×
120
            ~block_window_duration
121
        in
UNCOV
122
        List.map (List.take works per_reader) ~f:create_work
×
UNCOV
123
        |> List.map ~f:(fun work ->
×
UNCOV
124
               ( Envelope.Incoming.local work
×
UNCOV
125
               , Mina_net2.Validation_callback.create_without_expiration () ) )
×
126
        |> List.iter ~f:(fun diff ->
UNCOV
127
               Mock_snark_pool.Remote_sink.push remote_sink diff
×
128
               |> Deferred.don't_wait_for ) ;
UNCOV
129
        List.map (List.drop works per_reader) ~f:create_work
×
130
        |> List.iter ~f:(fun diff ->
UNCOV
131
               Mock_snark_pool.Local_sink.push local_sink (diff, Fn.const ())
×
132
               |> Deferred.don't_wait_for ) ;
UNCOV
133
        let%bind () = Mocks.Transition_frontier.refer_statements tf works in
×
UNCOV
134
        don't_wait_for
×
UNCOV
135
        @@ Linear_pipe.iter (Mock_snark_pool.broadcasts network_pool)
×
136
             ~f:(fun With_nonce.{ message = work_command; _ } ->
137
               let work =
×
138
                 match work_command with
139
                 | Mock_snark_pool.Resource_pool.Diff.Add_solved_work (work, _)
×
140
                   ->
141
                     work
142
                 | Mock_snark_pool.Resource_pool.Diff.Empty ->
143
                     assert false
144
               in
145
               assert (
×
146
                 List.mem works work
×
147
                   ~equal:Transaction_snark_work.Statement.equal ) ;
148
               Deferred.unit ) ;
UNCOV
149
        Deferred.unit
×
150
      in
151
      verify_unsolved_work |> Async.Thread_safe.block_on_async_exn
152
  end )
4✔
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