Test: move test/proto_alpha into proto_alpha/lib_client/test

This commit is contained in:
Grégoire Henry 2018-02-02 17:38:35 +01:00
parent 4d5e55595b
commit f7668c3799
21 changed files with 63 additions and 38 deletions

View File

@ -26,7 +26,7 @@ let handle_error res log_file_name =
ignore (Sys.command (Printf.sprintf "cat %s" log_file_name) : int) ; ignore (Sys.command (Printf.sprintf "cat %s" log_file_name) : int) ;
raise Node_exited_prematurely raise Node_exited_prematurely
let fork_node ?(timeout = 4) ?(port = 18732) ?sandbox () = let fork_node ?exe ?(timeout = 4) ?(port = 18732) ?sandbox () =
let data_dir = let data_dir =
Printf.sprintf Printf.sprintf
"%s/tezos_node_%6X" "%s/tezos_node_%6X"
@ -37,14 +37,17 @@ let fork_node ?(timeout = 4) ?(port = 18732) ?sandbox () =
let log_fd = Unix.descr_of_out_channel log_file in let log_fd = Unix.descr_of_out_channel log_file in
let null_fd = Unix.(openfile "/dev/null" [O_RDONLY] 0o644) in let null_fd = Unix.(openfile "/dev/null" [O_RDONLY] 0o644) in
let exe = let exe =
let (//) = Filename.concat in match exe with
try | Some exe -> exe
let path = Sys.argv.(1) in | None ->
if Filename.is_relative path then let (//) = Filename.concat in
Sys.getcwd () // ".." // path try
else let path = Sys.argv.(1) in
path if Filename.is_relative path then
with _ -> Sys.getcwd () // ".." // "bin_node" // "main.exe" in Sys.getcwd () // ".." // path
else
path
with _ -> Sys.getcwd () // ".." // "bin_node" // "main.exe" in
Format.eprintf "EXE %s@." exe ; Format.eprintf "EXE %s@." exe ;
let pid = let pid =
Unix.create_process exe Unix.create_process exe

View File

@ -8,7 +8,8 @@
(**************************************************************************) (**************************************************************************)
val fork_node: val fork_node:
?timeout:int -> ?port:int -> ?sandbox:string -> unit -> int ?exe:string -> ?timeout:int -> ?port:int -> ?sandbox:string ->
unit -> int
(** [fork_node ()] forks a node in sandbox mode listening to rpc on (** [fork_node ()] forks a node in sandbox mode listening to rpc on
`localhost:port` (where the default port is 18732) and returns the `localhost:port` (where the default port is 18732) and returns the
PID of the forked process. It waits `timeout` seconds (default 4) PID of the forked process. It waits `timeout` seconds (default 4)

View File

@ -31,9 +31,8 @@
(alias (alias
((name runtest_endorsement) ((name runtest_endorsement)
(deps (sandbox.json))
(locks (/tcp-port/18100)) (locks (/tcp-port/18100))
(action (chdir ${ROOT} (run ${exe:test_endorsement.exe} ${bin:tezos-node}))))) (action (chdir ${ROOT} (run ${exe:test_endorsement.exe} ${bin:tezos-node} ${path:sandbox.json} 18100)))))
(alias (alias
((name runtest_michelson_parser) ((name runtest_michelson_parser)
@ -41,21 +40,18 @@
(alias (alias
((name runtest_origination) ((name runtest_origination)
(deps (sandbox.json))
(locks (/tcp-port/18200)) (locks (/tcp-port/18200))
(action (chdir ${ROOT} (run ${exe:test_origination.exe} ${bin:tezos-node}))))) (action (chdir ${ROOT} (run ${exe:test_origination.exe} ${bin:tezos-node} ${path:sandbox.json} 18200)))))
(alias (alias
((name runtest_transaction) ((name runtest_transaction)
(deps (sandbox.json))
(locks (/tcp-port/18300)) (locks (/tcp-port/18300))
(action (chdir ${ROOT} (run ${exe:test_transaction.exe} ${bin:tezos-node}))))) (action (chdir ${ROOT} (run ${exe:test_transaction.exe} ${bin:tezos-node} ${path:sandbox.json} 18300)))))
(alias (alias
((name runtest_vote) ((name runtest_vote)
(deps (sandbox-vote.json))
(locks (/tcp-port/18400)) (locks (/tcp-port/18400))
(action (chdir ${ROOT} (run ${exe:test_vote.exe} ${bin:tezos-node}))))) (action (chdir ${ROOT} (run ${exe:test_vote.exe} ${bin:tezos-node} ${path:sandbox-vote.json} 18400)))))
(alias (alias
((name runtest) ((name runtest)

View File

@ -45,23 +45,17 @@ let activate_alpha () =
fitness }) fitness })
dictator_sk dictator_sk
let init ?(sandbox = "sandbox.json") ?rpc_port () = let init ?exe ?(sandbox = "sandbox.json") ?rpc_port () =
begin begin
match rpc_port with match rpc_port with
| None -> () | None -> ()
| Some port -> rpc_config := { !rpc_config with port } | Some port -> rpc_config := { !rpc_config with port }
end ; end ;
(* Handles relative path on OSX *)
let executable_path =
if Filename.is_relative Sys.argv.(0)
then Filename.concat (Sys.getcwd ()) Sys.argv.(0)
else Sys.argv.(0) in
Unix.chdir (Filename.dirname executable_path) ;
Unix.chdir ".." ;
let pid = let pid =
Node_helpers.fork_node Node_helpers.fork_node
?exe
~port:!rpc_config.port ~port:!rpc_config.port
~sandbox:(Filename.dirname executable_path // sandbox) ~sandbox
() in () in
activate_alpha () >>=? fun hash -> activate_alpha () >>=? fun hash ->
return (pid, hash) return (pid, hash)

View File

@ -11,6 +11,7 @@ open Proto_alpha
open Tezos_context open Tezos_context
val init : val init :
?exe:string ->
?sandbox:string -> ?sandbox:string ->
?rpc_port:int -> ?rpc_port:int ->
unit -> (int * Block_hash.t) tzresult Lwt.t unit -> (int * Block_hash.t) tzresult Lwt.t

View File

@ -240,8 +240,12 @@ let run genesis =
return () return ()
let exe = try Sys.argv.(1) with _ -> "tezos-node"
let sandbox = try Sys.argv.(2) with _ -> "sandbox.json"
let rpc_port = try int_of_string Sys.argv.(3) with _ -> 18100
let main () = let main () =
Helpers.init ~rpc_port:18100 () >>=? fun (_node_pid, genesis) -> Helpers.init ~exe ~sandbox ~rpc_port () >>=? fun (_node_pid, genesis) ->
run (`Hash genesis) run (`Hash genesis)

View File

@ -86,9 +86,13 @@ let run blkid ({ b1 ; b2 ; _ } : Helpers.Account.bootstrap_accounts) =
return blkh return blkh
let exe = try Sys.argv.(1) with _ -> "tezos-node"
let sandbox = try Sys.argv.(2) with _ -> "sandbox.json"
let rpc_port = try int_of_string Sys.argv.(3) with _ -> 18200
let main () = let main () =
Helpers.init ~rpc_port:18200 () >>=? fun (_node_pid, hash) -> Helpers.init ~exe ~sandbox ~rpc_port () >>=? fun (_node_pid, genesis) ->
run (`Hash hash) Helpers.Account.bootstrap_accounts >>=? fun _blkh -> run (`Hash genesis) Helpers.Account.bootstrap_accounts >>=? fun _blkh ->
return () return ()
let tests = [ let tests = [

View File

@ -97,9 +97,13 @@ let run blkid ({ b1 ; b2 ; b3 ; _ } : Helpers.Account.bootstrap_accounts) =
return blkh return blkh
let exe = try Sys.argv.(1) with _ -> "tezos-node"
let sandbox = try Sys.argv.(2) with _ -> "sandbox.json"
let rpc_port = try int_of_string Sys.argv.(3) with _ -> 18300
let main () = let main () =
Helpers.init ~rpc_port:18300 () >>=? fun (_node_pid, hash) -> Helpers.init ~exe ~sandbox ~rpc_port () >>=? fun (_node_pid, genesis) ->
run (`Hash hash) Helpers.Account.bootstrap_accounts >>=? fun _blkh -> run (`Hash genesis) Helpers.Account.bootstrap_accounts >>=? fun _blkh ->
return () return ()
let tests = [ let tests = [

View File

@ -85,8 +85,12 @@ let run_change_to_demo_proto block
return (`Hash head) return (`Hash head)
let exe = try Sys.argv.(1) with _ -> "tezos-node"
let sandbox = try Sys.argv.(2) with _ -> "sandbox-vote.json"
let rpc_port = try int_of_string Sys.argv.(3) with _ -> 18400
let change_to_demo_proto () = let change_to_demo_proto () =
init ~sandbox:"sandbox-vote.json" ~rpc_port:18400 () >>=? fun (_node_pid, hash) -> init ~exe ~sandbox ~rpc_port () >>=? fun (_node_pid, hash) ->
run_change_to_demo_proto (`Hash hash) Account.bootstrap_accounts >>=? fun _blkh -> run_change_to_demo_proto (`Hash hash) Account.bootstrap_accounts >>=? fun _blkh ->
return () return ()

View File

@ -14,6 +14,9 @@ depends: [
"tezos-protocol-alpha" "tezos-protocol-alpha"
"tezos-shell-services" "tezos-shell-services"
"tezos-client-base" "tezos-client-base"
"tezos-test-helpers" { test }
"tezos-node" { test }
"tezos-client-genesis" { test }
] ]
build: [ build: [
[ "jbuilder" "build" "-p" name "-j" jobs ] [ "jbuilder" "build" "-p" name "-j" jobs ]

View File

@ -71,8 +71,7 @@ let commands () =
~name:"password" ~desc:"Dictator's key" ~name:"password" ~desc:"Dictator's key"
@@ stop) @@ stop)
begin fun timestamp hash fitness sk (cctxt : Client_commands.full_context) -> begin fun timestamp hash fitness sk (cctxt : Client_commands.full_context) ->
let fitness = let fitness = Proto_alpha.Fitness_repr.from_int64 fitness in
Tezos_client_alpha.Proto_alpha.Fitness_repr.from_int64 fitness in
bake cctxt ?timestamp cctxt#block bake cctxt ?timestamp cctxt#block
(Activate { protocol = hash ; fitness }) (Activate { protocol = hash ; fitness })
sk >>=? fun hash -> sk >>=? fun hash ->

View File

@ -7,8 +7,8 @@
tezos-shell-services tezos-shell-services
tezos-client-base tezos-client-base
tezos-protocol-environment-client tezos-protocol-environment-client
tezos-client-alpha tezos-protocol-genesis
tezos-protocol-genesis)) tezos-protocol-alpha))
(library_flags (:standard -linkall)) (library_flags (:standard -linkall))
(flags (:standard -w -9+27-30-32-40@8 (flags (:standard -w -9+27-30-32-40@8
-safe-string -safe-string

View File

@ -0,0 +1,12 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
module Name = struct let name = "genesis-alpha" end
module Environment = Tezos_protocol_environment_client.Fake.Make(Name)()
include Tezos_protocol_alpha.Functor.Make(Environment)

View File

@ -13,8 +13,8 @@ depends: [
"tezos-shell-services" "tezos-shell-services"
"tezos-client-base" "tezos-client-base"
"tezos-protocol-environment-client" "tezos-protocol-environment-client"
"tezos-client-alpha"
"tezos-protocol-genesis" "tezos-protocol-genesis"
"tezos-protocol-alpha"
] ]
build: [ build: [
[ "jbuilder" "build" "-p" name "-j" jobs ] [ "jbuilder" "build" "-p" name "-j" jobs ]