Skip to content

Commit 0e033a9

Browse files
adds 200k block load by hash test
fixup: removed extra teardown
1 parent 2463c85 commit 0e033a9

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

deku-p/src/core/block_storage/tests/block_storage_tests.ml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ let test_200k_block_load env () =
116116
try
117117
Eio.Switch.run @@ fun sw ->
118118
let block_storage = make_block_storage env sw in
119-
let (Block { hash; _ } as block) = block ~default_block_size:200_000 in
119+
let (Block { hash; level; _ } as block) =
120+
block ~default_block_size:200_000
121+
in
120122
Block_storage.save_block ~block block_storage;
121123
let retrieved_block =
122124
match Block_storage.find_block_by_hash ~block_hash:hash block_storage with
@@ -127,9 +129,24 @@ let test_200k_block_load env () =
127129
~msg:"hash loaded block is equal to saved block" ~expected:block
128130
~actual:retrieved_block;
129131

132+
let retrieved_block =
133+
match Block_storage.find_block_by_level ~level block_storage with
134+
| Some json ->
135+
Data_encoding.Json.destruct Deku_consensus.Block.encoding json
136+
| None -> Genesis.block
137+
in
138+
139+
Alcotest.(check' block_testable)
140+
~msg:"level loaded block is equal to saved block" ~expected:block
141+
~actual:retrieved_block;
142+
130143
Eio.Switch.fail sw Test_finished
131144
with _ -> ()
132145

146+
(* TODO: Add tests with only one env threaded through all tests *)
147+
let eio_test_case : (Eio.Stdenv.t -> unit -> unit) -> unit -> unit =
148+
fun f () -> Eio_main.run (fun env -> f env ())
149+
133150
let run () =
134151
Eio_main.run (fun env ->
135152
let open Alcotest in

0 commit comments

Comments
 (0)