Skip to content

Commit

Permalink
(test) Continue rewriting
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac-DeFrain committed Jul 5, 2023
1 parent 39ccdf4 commit b5b3234
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 307 deletions.
16 changes: 4 additions & 12 deletions src/app/test_executive/block_production_priority.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@ open Core
open Integration_test_lib

module Make (Inputs : Intf.Test.Inputs_intf) = struct
open Inputs
open Engine
open Dsl
open Inputs.Dsl
open Inputs.Engine

open Test_common.Make (Inputs)

(* TODO: find a way to avoid this type alias (first class module signatures restrictions make this tricky) *)
type network = Network.t

type node = Network.Node.t

type dsl = Dsl.t

let test_name = "block-prod-prio"

let num_extra_keys = 1000
Expand Down Expand Up @@ -112,7 +104,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
let window_ms =
(Network.constraint_constants network).block_window_duration_ms
in
let%bind () = Wait_for.all_nodes_to_initialize network t in
let%bind () = Wait_for.all_nodes_to_initialize t network in
let%bind () =
section_hard "wait for 3 blocks to be produced (warm-up)"
(Wait_for.blocks_to_be_produced t 3)
Expand Down Expand Up @@ -222,7 +214,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
[%log info]
"Observer %s started again, will now wait for this node to initialize"
(Network.Node.id observer) ;
let%bind () = Wait_for.node_to_initialize t observer in
let%bind () = Wait_for.nodes_to_initialize t [ observer ] in
Wait_for.with_timeouts t
~condition:(Wait_condition.nodes_to_synchronize [ receiver; observer ])
~soft_timeout:(Network_time_span.Slots 3)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
open Integration_test_lib
open Core_kernel

module Make (Engine : Intf.Engine.S) (Dsl : Intf.Dsl.S with module Engine := Engine) = struct
open Engine
open Dsl
module Make (Inputs : Intf.Test.Inputs_intf) = struct
open Inputs.Dsl
open Inputs.Engine
open Test_common.Make (Inputs)

(* TODO: find a way to avoid this type alias (first class module signatures restrictions make this tricky) *)
type network = Network.t

type node = Network.Node.t

type dsl = Dsl.t
let test_name = "block_prod_timed"

let block_producer_balance = "1000"

Expand Down
14 changes: 3 additions & 11 deletions src/app/test_executive/block_reward_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,11 @@ open Integration_test_lib
open Mina_base

module Make (Inputs : Intf.Test.Inputs_intf) = struct
open Inputs
open Engine
open Dsl
open Inputs.Dsl
open Inputs.Engine

open Test_common.Make (Inputs)

(* TODO: find a way to avoid this type alias (first class module signatures restrictions make this tricky) *)
type network = Network.t

type node = Network.Node.t

type dsl = Dsl.t

let test_name = "block-reward"

let config =
Expand All @@ -30,7 +22,7 @@ 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
let%bind () = Wait_for.all_nodes_to_initialize network t in
let%bind () = Wait_for.all_nodes_to_initialize t network in
let node = get_bp_node network "node" in
let%bind bp_pk = pub_key_of_node node in
let bp_pk_account_id = Account_id.create bp_pk Token_id.default in
Expand Down
16 changes: 4 additions & 12 deletions src/app/test_executive/chain_reliability_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@ open Core
open Integration_test_lib

module Make (Inputs : Intf.Test.Inputs_intf) = struct
open Inputs
open Engine
open Dsl
open Inputs.Dsl
open Inputs.Engine

open Test_common.Make (Inputs)

(* TODO: find a way to avoid this type alias (first class module signatures restrictions make this tricky) *)
type network = Network.t

type node = Network.Node.t

type dsl = Dsl.t

let test_name = "chain-reliability"

let config =
Expand All @@ -38,7 +30,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
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%bind () = Wait_for.all_nodes_to_initialize network t 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 node_c = get_bp_node network "node-c" in
Expand All @@ -55,7 +47,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
[%log info]
"%s started again, will now wait for this node to initialize"
(Node.id node_c) ;
let%bind () = Wait_for.node_to_initialize t node_c in
let%bind () = Wait_for.nodes_to_initialize t [ node_c ] in
Wait_for.with_timeouts t
~condition:
(Wait_condition.nodes_to_synchronize [ node_a; node_b; node_c ])
Expand Down
19 changes: 5 additions & 14 deletions src/app/test_executive/delegation_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@ open Core_kernel
open Integration_test_lib

module Make (Inputs : Intf.Test.Inputs_intf) = struct
open Inputs
open Engine
open Dsl
open Inputs.Dsl
open Inputs.Engine

open Test_common.Make (Inputs)

(* TODO: find a way to avoid this type alias (first class module signatures restrictions make this tricky) *)
type network = Network.t

type node = Network.Node.t

type dsl = Dsl.t

let test_name = "delegation"

let config =
Expand All @@ -37,7 +29,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
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 network t 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 () =
Expand All @@ -55,9 +47,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
~sender_pub_key:delegation_sender_pub_key
~receiver_pub_key:delegation_receiver_pub_key ~fee
in
wait_for t
(Wait_condition.signed_command_to_be_included_in_frontier
~txn_hash:hash ~node_included_in:`Any_node ) )
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 =
Expand Down
14 changes: 3 additions & 11 deletions src/app/test_executive/gossip_consistency.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@ open Core
open Integration_test_lib

module Make (Inputs : Intf.Test.Inputs_intf) = struct
open Inputs
open Engine
open Dsl
open Inputs.Dsl
open Inputs.Engine

open Test_common.Make (Inputs)

(* TODO: find a way to avoid this type alias (first class module signatures restrictions make this tricky) *)
type network = Network.t

type node = Network.Node.t

type dsl = Dsl.t

let test_name = "gossip-consis"

let config =
Expand All @@ -35,7 +27,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
let open Malleable_error.Let_syntax in
let logger = Logger.create ~prefix:(test_name ^ " test: ") () in
[%log info] "starting..." ;
let%bind () = Wait_for.all_nodes_to_initialize network t in
let%bind () = Wait_for.all_nodes_to_initialize t network in
[%log info] "done waiting for initializations" ;
let receiver_bp = get_bp_node network "node-a" in
let%bind receiver_pub_key = pub_key_of_node receiver_bp in
Expand Down
21 changes: 6 additions & 15 deletions src/app/test_executive/medium_bootstrap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,11 @@ open Async
open Integration_test_lib

module Make (Inputs : Intf.Test.Inputs_intf) = struct
open Inputs
open Engine
open Dsl
open Inputs.Dsl
open Inputs.Engine

open Test_common.Make (Inputs)

(* TODO: find a way to avoid this type alias (first class module signatures restrictions make this tricky) *)
type network = Network.t

type node = Network.Node.t

type dsl = Dsl.t

let test_name = "medium-bootstrap"

let config =
Expand Down Expand Up @@ -46,11 +38,10 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
(* this test is the medium bootstrap test *)

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%bind () = Wait_for.all_nodes_to_initialize network t 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 node_c = get_bp_node network "node-c" in
Expand All @@ -67,13 +58,13 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
[%log info]
"%s started again, will now wait for this node to initialize"
(Node.id node_c) ;
let%bind () = Wait_for.node_to_initialize t node_c in
let%bind () = Wait_for.nodes_to_initialize t [ node_c ] in
Wait_for.nodes_to_synchronize t [ node_a; node_b; node_c ] )
in
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 network)
in
assert_peers_completely_connected final_connectivity_data )
end
52 changes: 15 additions & 37 deletions src/app/test_executive/payments_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@ open Integration_test_lib
open Mina_base

module Make (Inputs : Intf.Test.Inputs_intf) = struct
open Inputs
open Engine
open Dsl
open Inputs.Dsl
open Inputs.Engine

open Test_common.Make (Inputs)

(* TODO: find a way to avoid this type alias (first class module signatures restrictions make this tricky) *)
type network = Network.t

type node = Network.Node.t

type dsl = Dsl.t

let test_name = "payments"

(* TODO: refactor all currency values to decimal represenation *)
Expand Down Expand Up @@ -83,17 +75,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
let open Network in
let open Malleable_error.Let_syntax in
let logger = Logger.create ~prefix:(test_name ^ " test: ") () in
let%bind () = Wait_for.all_nodes_to_initialize network t in
let untimed_node_a =
Core.String.Map.find_exn
(Network.block_producers network)
"untimed-node-a"
in
let untimed_node_b =
Core.String.Map.find_exn
(Network.block_producers network)
"untimed-node-b"
in
let%bind () = Wait_for.all_nodes_to_initialize t network in
let untimed_node_a = get_bp_node network "untimed-node-a" in
let untimed_node_b = get_bp_node network "untimed-node-b" in
let timed_node_c = get_bp_node network "timed-node-c" in
let fish1 = get_genesis_keypair network "fish1" in
let fish2 = get_genesis_keypair network "fish2" in
Expand All @@ -102,9 +86,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
~f:(fun { Signature_lib.Keypair.public_key; _ } ->
public_key |> Signature_lib.Public_key.to_bigstring
|> Bigstring.to_string ) ) ;
let snark_coordinator =
Core.String.Map.find_exn (Network.all_nodes network) "snark-node"
in
let snark_coordinator = get_node network "snark-node" in
let snark_node_key1 = get_genesis_keypair network "snark-node-key1" in
let snark_node_key2 = get_genesis_keypair network "snark-node-key2" in
[%log info] "snark node keypairs: %s"
Expand All @@ -115,7 +97,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
(* create a signed txn which we'll use to make a successfull txn, and then a replay attack *)
let amount = Currency.Amount.of_mina_string_exn "10" in
let fee = Currency.Fee.of_mina_string_exn "1" in
let test_constants = Engine.Network.constraint_constants network in
let test_constants = Network.constraint_constants network in
let receiver_pub_key =
fish1.keypair.public_key |> Signature_lib.Public_key.compress
in
Expand Down Expand Up @@ -189,9 +171,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
~raw_signature:
(Mina_base.Signature.Raw.encode signed_cmmd.signature)
in
wait_for t
(Wait_condition.signed_command_to_be_included_in_frontier
~txn_hash:hash ~node_included_in:(`Node untimed_node_b) ) )
Wait_for.signed_command_to_be_included_in_frontier t ~txn_hash:hash
~node_included_in:(`Node untimed_node_b) )
in
let%bind () =
section
Expand Down Expand Up @@ -383,9 +364,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
Network.Node.must_send_payment ~logger timed_node_c ~sender_pub_key
~receiver_pub_key ~amount ~fee
in
wait_for t
(Wait_condition.signed_command_to_be_included_in_frontier
~txn_hash:hash ~node_included_in:(`Node timed_node_c) ) )
Wait_for.signed_command_to_be_included_in_frontier t ~txn_hash:hash
~node_included_in:(`Node timed_node_c) )
in
let%bind () =
section "unable to send payment from timed account using illiquid tokens"
Expand Down Expand Up @@ -459,9 +439,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
send_payments ~logger ~sender_pub_key ~receiver_pub_key
~amount:Currency.Amount.one ~fee ~node:sender 10
in
wait_for t
(Wait_condition.ledger_proofs_emitted_since_genesis
~test_config:config ~num_proofs:1 ) )
Wait_for.ledger_proofs_emitted_since_genesis t ~test_config:config
~num_proofs:1 )
in
let%bind () =
section_hard
Expand Down Expand Up @@ -539,9 +518,8 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
send_payments ~logger ~sender_pub_key ~receiver_pub_key
~amount:Currency.Amount.one ~fee ~node:sender 12
in
wait_for t
(Wait_condition.ledger_proofs_emitted_since_genesis ~num_proofs:2
~test_config:config ) )
Wait_for.ledger_proofs_emitted_since_genesis t ~num_proofs:2
~test_config:config )
in
let%bind () =
section_hard
Expand Down
Loading

0 comments on commit b5b3234

Please sign in to comment.