Skip to content

Commit

Permalink
(test exec) Update with new common functions and modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac-DeFrain committed Jul 5, 2023
1 parent 1aacf66 commit 170411c
Show file tree
Hide file tree
Showing 11 changed files with 298 additions and 285 deletions.
7 changes: 3 additions & 4 deletions src/app/test_executive/chain_reliability_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
let module Node = Network.Node in
let open Malleable_error.Let_syntax in
let logger = Logger.create ~prefix:(test_name ^ "test: ") () in
let all_nodes = Network.all_nodes network in
let all_nodes = all_nodes network in
let%bind () = Wait_for.all_nodes_to_initialize t network in
let node_a = get_bp_node network "node-a" in
let node_b = get_bp_node network "node-b" in
Expand Down Expand Up @@ -75,7 +75,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
let fee = Currency.Fee.of_mina_string_exn "1" in
[%log info] "will now send %d payments" num_payments ;
let%bind hashlist =
send_payments ~logger ~sender_pub_key ~receiver_pub_key
Payment_util.send_n ~logger ~sender_pub_key ~receiver_pub_key
~node:sender_bp ~fee ~amount num_payments
in
[%log info] "sending payments done. will now wait for payments" ;
Expand All @@ -89,8 +89,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
section "common prefix of all nodes is no farther back than 1 block"
(* the common prefix test relies on at least 4 blocks having been produced. previous sections altogether have already produced 4, so no further block production is needed. if previous sections change, then this may need to be re-adjusted*)
(let%bind (labeled_chains : (string * string list) list) =
Malleable_error.List.map (Core.String.Map.data all_nodes)
~f:(fun node ->
Malleable_error.List.map all_nodes ~f:(fun node ->
let%map chain = Network.Node.must_get_best_chain ~logger node in
(Node.id node, List.map ~f:(fun b -> b.state_hash) chain) )
in
Expand Down
21 changes: 5 additions & 16 deletions src/app/test_executive/delegation_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,22 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
let run network t =
let open Malleable_error.Let_syntax in
let logger = Logger.create ~prefix:(test_name ^ "test: ") () in
(* fee for user commands *)
let fee = Currency.Fee.of_nanomina_int_exn 10_000_000 in
let%bind () = Wait_for.all_nodes_to_initialize t network in
let node_a = get_bp_node network "node-a" in
let node_b = get_bp_node network "node-b" in
let%bind () =
section "Delegate all tokens from node_b to node_a"
(let delegation_receiver = node_a in
let%bind delegation_receiver_pub_key =
pub_key_of_node delegation_receiver
in
let delegation_sender = node_b in
let%bind delegation_sender_pub_key =
pub_key_of_node delegation_sender
in
(let%bind delegation_receiver_pub_key = pub_key_of_node node_a in
let%bind delegation_sender_pub_key = pub_key_of_node node_b in
let fee = Currency.Fee.of_nanomina_int_exn 10_000_000 in
let%bind { hash; _ } =
Network.Node.must_send_delegation ~logger delegation_sender
Network.Node.must_send_delegation ~logger node_b
~sender_pub_key:delegation_sender_pub_key
~receiver_pub_key:delegation_receiver_pub_key ~fee
in
Wait_for.signed_command_to_be_included_in_frontier t ~txn_hash:hash
~node_included_in:`Any_node )
in
section_hard "Running replayer"
(let%bind logs =
Network.Node.run_replayer ~logger
(List.hd_exn @@ Core.String.Map.data (Network.archive_nodes network))
in
check_replayer_logs ~logger logs )
(Archive_node.run_and_check_replayer ~logger network)
end
4 changes: 2 additions & 2 deletions src/app/test_executive/gossip_consistency.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
let amount = Currency.Amount.of_nanomina_int_exn 10_000_000 in
[%log info] "will now send %d payments" num_payments ;
let%bind hashlist =
send_payments ~logger ~sender_pub_key ~receiver_pub_key ~node:sender_bp
~fee ~amount num_payments
Payment_util.send_n ~logger ~sender_pub_key ~receiver_pub_key
~node:sender_bp ~fee ~amount num_payments
in
[%log info] "sending payments done. will now wait for payments" ;
let%bind () =
Expand Down
10 changes: 3 additions & 7 deletions src/app/test_executive/payments_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
Hence, 6*2 = 12 transactions untill we get the first snarked ledger.
2 successful txn are sent in the prior course of this test,
so spamming out at least 10 more here will trigger a ledger proof to be emitted *)
send_payments ~logger ~sender_pub_key ~receiver_pub_key
Payment_util.send_n ~logger ~sender_pub_key ~receiver_pub_key
~amount:Currency.Amount.one ~fee ~node:sender 10
in
Wait_for.ledger_proofs_emitted_since_genesis t ~test_config:config
Expand Down Expand Up @@ -515,7 +515,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
let sender = untimed_node_a in
let%bind sender_pub_key = pub_key_of_node sender in
let%bind _ =
send_payments ~logger ~sender_pub_key ~receiver_pub_key
Payment_util.send_n ~logger ~sender_pub_key ~receiver_pub_key
~amount:Currency.Amount.one ~fee ~node:sender 12
in
Wait_for.ledger_proofs_emitted_since_genesis t ~num_proofs:2
Expand Down Expand Up @@ -574,9 +574,5 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
config.snark_worker_fee )
in
section_hard "running replayer"
(let%bind logs =
Network.Node.run_replayer ~logger
(List.hd_exn @@ (Network.archive_nodes network |> Core.Map.data))
in
check_replayer_logs ~logger logs )
(Archive_node.run_and_check_replayer ~logger network)
end
25 changes: 9 additions & 16 deletions src/app/test_executive/peers_reliability_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
}

let run network t =
let open Network in
let module Node = Network.Node in
let open Malleable_error.Let_syntax in
let logger = Logger.create ~prefix:(test_name ^ " test: ") () in
let all_nodes = Network.all_nodes network in
let all_nodes = all_nodes network in
[%log info] "peers_list"
~metadata:
[ ( "peers"
, `List
(List.map (Core.String.Map.data all_nodes) ~f:(fun n ->
`String (Node.id n) ) ) )
[ ("peers", `List (List.map all_nodes ~f:(fun n -> `String (Node.id n))))
] ;
let node_a = get_bp_node network "node-a" in
let node_b = get_bp_node network "node-b" in
Expand All @@ -54,12 +51,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
(Time.Span.of_ms (20. *. 60. *. 1000.)) ) )
in
(* let%bind () = wait_for t (Wait_condition.nodes_to_initialize [ node_c ]) in *)
let%bind () =
wait_for t
(Wait_condition.nodes_to_initialize (Core.String.Map.data all_nodes))
in
let%bind () = Wait_for.all_nodes_to_initialize t network in
let%bind initial_connectivity_data =
fetch_connectivity_data ~logger (Core.String.Map.data all_nodes)
fetch_connectivity_data ~logger all_nodes
in
let%bind () =
section "network is fully connected upon initialization"
Expand All @@ -83,9 +77,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
~amount:(Currency.Amount.of_nanomina_int_exn 1_000_000)
~fee:(Currency.Fee.of_nanomina_int_exn 10_000_000)
in
wait_for t
(Wait_condition.signed_command_to_be_included_in_frontier ~txn_hash
~node_included_in:(`Node node_c) ) )
Wait_for.signed_command_to_be_included_in_frontier t ~txn_hash
~node_included_in:(`Node node_c) )
in
let zkapp_account_keypair = Signature_lib.Keypair.create () in
let%bind () =
Expand Down Expand Up @@ -128,7 +121,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
~constraint_constants:(Network.constraint_constants network)
parties_spec
in
let%bind () = Zkapp.send ~logger node_c parties_create_accounts in
let%bind () = Zkapp_util.send ~logger node_c parties_create_accounts in
wait_for_zkapp parties_create_accounts )
in
let%bind () =
Expand Down Expand Up @@ -183,7 +176,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
section "network is fully connected after one node was restarted"
(let%bind () = Malleable_error.lift (after (Time.Span.of_sec 240.0)) in
let%bind final_connectivity_data =
fetch_connectivity_data ~logger (Core.String.Map.data all_nodes)
fetch_connectivity_data ~logger all_nodes
in
assert_peers_completely_connected final_connectivity_data )
end
Loading

0 comments on commit 170411c

Please sign in to comment.