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) ;
raise Node_exited_prematurely
let fork_node ?(timeout = 4) ?(port = 18732) ?sandbox () =
let fork_node ?exe ?(timeout = 4) ?(port = 18732) ?sandbox () =
let data_dir =
Printf.sprintf
"%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 null_fd = Unix.(openfile "/dev/null" [O_RDONLY] 0o644) in
let exe =
let (//) = Filename.concat in
try
let path = Sys.argv.(1) in
if Filename.is_relative path then
Sys.getcwd () // ".." // path
else
path
with _ -> Sys.getcwd () // ".." // "bin_node" // "main.exe" in
match exe with
| Some exe -> exe
| None ->
let (//) = Filename.concat in
try
let path = Sys.argv.(1) in
if Filename.is_relative path then
Sys.getcwd () // ".." // path
else
path
with _ -> Sys.getcwd () // ".." // "bin_node" // "main.exe" in
Format.eprintf "EXE %s@." exe ;
let pid =
Unix.create_process exe

View File

@ -8,7 +8,8 @@
(**************************************************************************)
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
`localhost:port` (where the default port is 18732) and returns the
PID of the forked process. It waits `timeout` seconds (default 4)

View File

@ -31,9 +31,8 @@
(alias
((name runtest_endorsement)
(deps (sandbox.json))
(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
((name runtest_michelson_parser)
@ -41,21 +40,18 @@
(alias
((name runtest_origination)
(deps (sandbox.json))
(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
((name runtest_transaction)
(deps (sandbox.json))
(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
((name runtest_vote)
(deps (sandbox-vote.json))
(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
((name runtest)

View File

@ -45,23 +45,17 @@ let activate_alpha () =
fitness })
dictator_sk
let init ?(sandbox = "sandbox.json") ?rpc_port () =
let init ?exe ?(sandbox = "sandbox.json") ?rpc_port () =
begin
match rpc_port with
| None -> ()
| Some port -> rpc_config := { !rpc_config with port }
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 =
Node_helpers.fork_node
?exe
~port:!rpc_config.port
~sandbox:(Filename.dirname executable_path // sandbox)
~sandbox
() in
activate_alpha () >>=? fun hash ->
return (pid, hash)

View File

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

View File

@ -240,8 +240,12 @@ let run genesis =
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 () =
Helpers.init ~rpc_port:18100 () >>=? fun (_node_pid, genesis) ->
Helpers.init ~exe ~sandbox ~rpc_port () >>=? fun (_node_pid, genesis) ->
run (`Hash genesis)

View File

@ -86,9 +86,13 @@ let run blkid ({ b1 ; b2 ; _ } : Helpers.Account.bootstrap_accounts) =
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 () =
Helpers.init ~rpc_port:18200 () >>=? fun (_node_pid, hash) ->
run (`Hash hash) Helpers.Account.bootstrap_accounts >>=? fun _blkh ->
Helpers.init ~exe ~sandbox ~rpc_port () >>=? fun (_node_pid, genesis) ->
run (`Hash genesis) Helpers.Account.bootstrap_accounts >>=? fun _blkh ->
return ()
let tests = [

View File

@ -97,9 +97,13 @@ let run blkid ({ b1 ; b2 ; b3 ; _ } : Helpers.Account.bootstrap_accounts) =
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 () =
Helpers.init ~rpc_port:18300 () >>=? fun (_node_pid, hash) ->
run (`Hash hash) Helpers.Account.bootstrap_accounts >>=? fun _blkh ->
Helpers.init ~exe ~sandbox ~rpc_port () >>=? fun (_node_pid, genesis) ->
run (`Hash genesis) Helpers.Account.bootstrap_accounts >>=? fun _blkh ->
return ()
let tests = [

View File

@ -85,8 +85,12 @@ let run_change_to_demo_proto block
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 () =
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 ->
return ()

View File

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

View File

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

View File

@ -7,8 +7,8 @@
tezos-shell-services
tezos-client-base
tezos-protocol-environment-client
tezos-client-alpha
tezos-protocol-genesis))
tezos-protocol-genesis
tezos-protocol-alpha))
(library_flags (:standard -linkall))
(flags (:standard -w -9+27-30-32-40@8
-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-client-base"
"tezos-protocol-environment-client"
"tezos-client-alpha"
"tezos-protocol-genesis"
"tezos-protocol-alpha"
]
build: [
[ "jbuilder" "build" "-p" name "-j" jobs ]