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

MinaProtocol / mina / 411

24 Jul 2025 03:14PM UTC coverage: 33.188% (-27.7%) from 60.871%
411

push

buildkite

web-flow
Merge pull request #17541 from MinaProtocol/brian/merge-compatible-into-develop

Merge compatible into develop

164 of 702 new or added lines in 96 files covered. (23.36%)

18243 existing lines in 393 files now uncovered.

23983 of 72264 relevant lines covered (33.19%)

24667.26 hits per line

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

81.82
/src/test/archive/archive_node_tests/archive_node_tests.ml
1
open Async
2
open Core
3
open Mina_automation
4
open Mina_automation_runner
5
open Mina_automation_fixture.Archive
6

7
(**
8
 * Test the basic functionality of the mina archive with mocked deamon
9
 *)
10

11
(* asserts count of archive blocked (we are skipping genesis block) *)
12
let assert_archived_blocks ~archive_uri ~expected =
13
  let connection = Psql.Conn_str archive_uri in
1✔
14
  let%bind actual_blocks_count =
15
    Psql.run_command ~connection
1✔
16
      "SELECT COUNT(*) FROM blocks WHERE global_slot_since_genesis > 1"
17
  in
18
  let actual_blocks_count =
1✔
19
    match actual_blocks_count with
20
    | Ok count ->
1✔
21
        count |> Int.of_string
1✔
NEW
22
    | Error err ->
×
NEW
23
        failwith ("Failed to query blocks count: " ^ Error.to_string_hum err)
×
24
  in
25
  if Int.( <> ) actual_blocks_count expected then
NEW
26
    failwithf "Invalid number of archive blocks. Actual (%d) vs Expected (%d)"
×
27
      actual_blocks_count expected ()
28
  else Deferred.unit
1✔
29

30
module ArchivePrecomputedBlocksFromDaemon = struct
31
  type t = Mina_automation_fixture.Archive.after_bootstrap
32

33
  let test_case (test_data : t) =
34
    let open Deferred.Let_syntax in
1✔
35
    let daemon = Daemon.default in
36
    let archive_uri = test_data.archive.config.postgres_uri in
37
    let output = test_data.temp_dir in
38
    let%bind precomputed_blocks =
39
      Network_data.untar_precomputed_blocks test_data.network_data output
1✔
40
    in
41
    let precomputed_blocks =
1✔
42
      List.map precomputed_blocks ~f:(fun file -> output ^ "/" ^ file)
1✔
43
      |> List.filter ~f:(fun file -> String.is_suffix file ~suffix:".json")
43✔
44
    in
45
    Archive.Process.start_logging test_data.archive ;
1✔
46
    let%bind () =
47
      Daemon.archive_blocks_from_files daemon
1✔
48
        ~archive_address:test_data.archive.config.server_port
49
        ~format:Archive_blocks.Precomputed precomputed_blocks
50
    in
51

52
    let%bind () =
53
      assert_archived_blocks ~archive_uri
54
        ~expected:(List.length precomputed_blocks)
1✔
55
    in
56
    let connection = Psql.Conn_str archive_uri in
1✔
57
    let%bind latest_state_hash =
58
      Psql.run_command ~connection
1✔
59
        "SELECT state_hash FROM blocks ORDER BY id DESC LIMIT 1"
60
    in
61
    let latest_state_hash =
1✔
62
      match latest_state_hash with
63
      | Ok hash ->
1✔
64
          hash
NEW
65
      | Error err ->
×
66
          failwith
NEW
67
            ("Failed to query latest state hash: " ^ Error.to_string_hum err)
×
68
    in
69
    let output_ledger = output ^ "/output_ledger.json" in
70
    let replayer = Replayer.default in
71
    let%bind replayer_output =
72
      Replayer.run replayer ~archive_uri
1✔
73
        ~input_config:
74
          (Network_data.replayer_input_file_path test_data.network_data)
1✔
75
        ~target_state_hash:latest_state_hash ~interval_checkpoint:10
76
        ~output_ledger ()
77
    in
78
    let () = print_endline replayer_output in
1✔
79
    let output_ledger = Replayer.Output.of_json_file_exn output_ledger in
1✔
80
    assert (
1✔
81
      String.equal output_ledger.target_epoch_ledgers_state_hash
1✔
82
        latest_state_hash ) ;
83
    Deferred.Or_error.return Mina_automation_fixture.Intf.Passed
84
end
85

86
let () =
87
  Backtrace.elide := false ;
88
  Async.Scheduler.set_record_backtraces true
1✔
89

90
let () =
91
  let open Alcotest in
NEW
92
  run "Test archive node."
×
93
    [ ( "precomputed blocks"
94
      , [ test_case "The mina daemon works in background mode" `Quick
1✔
95
            (Runner.run_blocking
1✔
96
               ( module Mina_automation_fixture.Archive.Make_FixtureWithBootstrap
97
                          (ArchivePrecomputedBlocksFromDaemon) ) )
98
        ] )
99
    ]
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