Skip to content

Commit

Permalink
adds 200k block load by hash test
Browse files Browse the repository at this point in the history
fixup: removed extra teardown
  • Loading branch information
InfiniteSwerve committed Dec 13, 2022
1 parent 4551bcb commit 90b597b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion deku-p/src/core/block_storage/tests/block_storage_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ let test_200k_block_load env () =
Parallel.Pool.run ~env ~domains:4 @@ fun () ->
Eio.Switch.run @@ fun sw ->
let block_storage = make_block_storage env sw in
let (Block { hash; _ } as block) = block ~default_block_size:200_000 in
let (Block { hash; level; _ } as block) =
block ~default_block_size:200_000
in
Block_storage.save_block ~block block_storage;
let retrieved_block =
match Block_storage.find_block_by_hash ~block_hash:hash block_storage with
Expand All @@ -133,9 +135,24 @@ let test_200k_block_load env () =
~msg:"hash loaded block is equal to saved block" ~expected:block
~actual:retrieved_block;

let retrieved_block =
match Block_storage.find_block_by_level ~level block_storage with
| Some json ->
Data_encoding.Json.destruct Deku_consensus.Block.encoding json
| None -> Genesis.block
in

Alcotest.(check' block_testable)
~msg:"level loaded block is equal to saved block" ~expected:block
~actual:retrieved_block;

Eio.Switch.fail sw Test_finished
with _ -> ()

(* TODO: Add tests with only one env threaded through all tests *)
let eio_test_case : (Eio.Stdenv.t -> unit -> unit) -> unit -> unit =
fun f () -> Eio_main.run (fun env -> f env ())

let run () =
Eio_main.run (fun env ->
let open Alcotest in
Expand Down

0 comments on commit 90b597b

Please sign in to comment.