@@ -3,6 +3,7 @@ open Deku_crypto
33open Deku_consensus
44open Deku_concepts
55open Deku_gossip
6+ open Deku_block_storage
67
78let block_testable = Alcotest. testable Block. pp Block. equal
89
@@ -35,19 +36,16 @@ let uri = Uri.of_string (Format.sprintf "sqlite3:/tmp/%s.db" file_hash)
3536let make_block_storage env sw =
3637 let domains = Eio.Stdenv. domain_mgr env in
3738 let worker = Parallel.Worker. make ~domains ~sw in
38- let storage = Deku_block_storage. Block_storage. make ~worker ~uri in
39+ let storage = Block_storage. make ~worker ~uri in
3940 storage
4041
4142let test_empty_block_load env () =
4243 Eio.Switch. run @@ fun sw ->
4344 let block_storage = make_block_storage env sw in
4445 let (Block { hash; level; _ } as block) = block ~default_block_size: 0 in
45- Deku_block_storage. Block_storage. save_block ~block block_storage;
46+ Block_storage. save_block ~block block_storage;
4647 let retrieved_block =
47- match
48- Deku_block_storage.Block_storage. find_block_by_hash ~block_hash: hash
49- block_storage
50- with
48+ match Block_storage. find_block_by_hash ~block_hash: hash block_storage with
5149 | Some json -> Block. t_of_yojson json
5250 | None -> Genesis. block
5351 in
@@ -56,9 +54,7 @@ let test_empty_block_load env () =
5654 ~actual: retrieved_block;
5755
5856 let retrieved_block =
59- match
60- Deku_block_storage.Block_storage. find_block_by_level ~level block_storage
61- with
57+ match Block_storage. find_block_by_level ~level block_storage with
6258 | Some json -> Block. t_of_yojson json
6359 | None -> Genesis. block
6460 in
@@ -68,9 +64,7 @@ let test_empty_block_load env () =
6864 ~actual: retrieved_block;
6965
7066 (* TODO: Fail the switch and capture the exception instead *)
71- let (Deku_block_storage.Block_storage. Storage { worker; _ }) =
72- block_storage
73- in
67+ let (Block_storage. Storage { worker; _ }) = block_storage in
7468 Parallel.Worker. teardown worker
7569
7670let test_empty_block_and_votes env () =
@@ -84,15 +78,11 @@ let test_empty_block_and_votes env () =
8478 let (Deku_gossip.Message. Message { header = _; content = _; network }) =
8579 Deku_gossip.Message. encode ~content
8680 in
87- Deku_block_storage.Block_storage. save_block_and_votes ~level ~network
88- block_storage;
81+ Block_storage. save_block_and_votes ~level ~network block_storage;
8982
9083 let retrieved_block_and_votes =
9184 let default_return = (Genesis. block, [] ) in
92- match
93- Deku_block_storage.Block_storage. find_block_and_votes_by_level ~level
94- block_storage
95- with
85+ match Block_storage. find_block_and_votes_by_level ~level block_storage with
9686 | Some (Message.Network. Network_message { raw_header; raw_content } ) -> (
9787 let expected = Message.Header. decode ~raw_header in
9888 let (Message. Message { content; _ }) =
@@ -108,9 +98,7 @@ let test_empty_block_and_votes env () =
10898 ~expected: (block, votes) ~actual: retrieved_block_and_votes;
10999
110100 (* TODO: Fail the switch and capture the exception instead *)
111- let (Deku_block_storage.Block_storage. Storage { worker; _ }) =
112- block_storage
113- in
101+ let (Block_storage. Storage { worker; _ }) = block_storage in
114102 Parallel.Worker. teardown worker
115103
116104(* TODO: Add tests with only one env threaded through all tests *)
0 commit comments