Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 200k block and vote load test #1014

Open
wants to merge 1 commit into
base: block-storage-tests-5
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions deku-p/src/core/block_storage/tests/block_storage_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,44 @@ let test_200k_block_load env () =
Eio.Switch.fail sw Test_finished
with _ -> ()

let test_200k_block_and_votes env () =
try
Eio.Switch.run @@ fun sw ->
let block_storage = make_block_storage env sw in
let (Block { hash; level; _ } as block) =
block ~default_block_size:200_000
in
let vote = make_vote ~hash identity in
let votes = Verified_signature.Set.add vote Verified_signature.Set.empty in
let votes = Verified_signature.Set.elements votes in
let content = Deku_gossip.Message.Content.accepted ~block ~votes in
let (Deku_gossip.Message.Message { header = _; content = _; network }) =
Deku_gossip.Message.encode ~content
in
Block_storage.save_block_and_votes ~level ~network block_storage;

let retrieved_block_and_votes =
let default_return = (Genesis.block, []) in
match
Block_storage.find_block_and_votes_by_level ~level block_storage
with
| Some (Message.Network.Network_message { raw_header; raw_content }) -> (
let expected = Message.Header.decode ~raw_header in
let (Message.Message { content; _ }) =
Message.decode ~expected ~raw_content
in
match content with
| Content_accepted { block; votes } -> (block, votes)
| _ -> default_return)
| None -> default_return
in
Alcotest.(check' (pair block_testable (list vote_testable)))
~msg:"retrieved empty block and one vote equal saved"
~expected:(block, votes) ~actual:retrieved_block_and_votes;

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

let run () =
Eio_main.run (fun env ->
let open Alcotest in
Expand All @@ -155,6 +193,8 @@ let run () =
(test_empty_block_and_votes env);
test_case "200k_block is returned" `Slow
(test_200k_block_load env);
test_case "200k_block_and_votes is returned" `Slow
(test_200k_block_and_votes env);
] );
])

Expand Down