Skip to content

Commit f2aaf27

Browse files
committed
Add test of root backing conversion
1 parent 14bc0c8 commit f2aaf27

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/lib/mina_ledger/test/test_mina_ledger.ml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,36 @@ module Root_test = struct
180180
~logger ~depth:ledger_depth ~assert_synced:true ()
181181
|> close) ) ;
182182
Deferred.unit )
183+
184+
(** Test that a root created with a stable backing and then made converting
185+
has the expected database states *)
186+
let test_root_make_converting ~random () =
187+
Mina_stdlib_unix.File_system.with_temp_dir "root_gradual_migration"
188+
~f:(fun cwd ->
189+
let cfg =
190+
L.Root.Config.with_directory ~directory_name:(cwd ^/ "ledger")
191+
in
192+
let root =
193+
L.Root.create ~logger
194+
~config:(cfg ~backing_type:Stable_db)
195+
~depth:ledger_depth ()
196+
in
197+
let loc_with_accounts =
198+
populate_with_random_accounts ~num:num_accounts ~root ~random
199+
in
200+
let%bind root = L.Root.make_converting root in
201+
(* Make sure the stable accounts are all still present *)
202+
assert_accounts ~loc_with_accounts ~root ;
203+
L.Root.close root ;
204+
(* Re-open the root as converting to check that the databases are in
205+
sync *)
206+
let converting_root =
207+
L.Root.create ~logger
208+
~config:(cfg ~backing_type:Converting_db)
209+
~depth:ledger_depth ~assert_synced:true ()
210+
in
211+
L.Root.close converting_root ;
212+
Deferred.unit )
183213
end
184214

185215
let () =
@@ -195,5 +225,7 @@ let () =
195225
(Root_test.test_root_moving ~random)
196226
; Alcotest_async.test_case "make checkpointing a root" `Quick
197227
(Root_test.test_root_make_checkpointing ~random)
228+
; Alcotest_async.test_case "make converting a root" `Quick
229+
(Root_test.test_root_make_converting ~random)
198230
] )
199231
] )

0 commit comments

Comments
 (0)