Client/Alpha: program -> script

This commit is contained in:
Vincent Bernardoff 2018-06-20 18:34:55 +02:00 committed by Benjamin Canou
parent 404774e091
commit 5e0822eb22
5 changed files with 44 additions and 44 deletions

View File

@ -60,8 +60,8 @@ $client get balance for $key2 | assert "2000 ꜩ"
bake
$client remember program noop file:contracts/noop.tz
$client typecheck program file:contracts/noop.tz
$client remember script noop file:contracts/noop.tz
$client typecheck script file:contracts/noop.tz
bake_after $client originate contract noop \
for $key1 transferring 1,000 from bootstrap1 \
running file:contracts/noop.tz

View File

@ -25,7 +25,7 @@ printf "\n\n"
if [ ! $NO_TYPECHECK ] ; then
for contract in `ls $contract_dir/*.tz`; do
printf "[Typechecking %s]\n" "$contract";
${client} typecheck program "$contract";
${client} typecheck script "$contract";
done
printf "All contracts are well typed\n\n"
fi
@ -235,59 +235,59 @@ assert_storage $contract_dir/hash_string.tz '"?"' '"12345"' '"expru81QVHsW2qaWLN
# Test ASSERT
assert_storage $contract_dir/assert.tz Unit True Unit
assert_fails $client run program $contract_dir/assert.tz on storage Unit and input False
assert_fails $client run script $contract_dir/assert.tz on storage Unit and input False
# COMPARE; ASSERT_
assert_storage $contract_dir/assert_eq.tz Unit '(Pair -1 -1)' Unit
assert_fails $client run program $contract_dir/assert_eq.tz on storage Unit and input '(Pair 0 -1)'
assert_fails $client run script $contract_dir/assert_eq.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_dir/assert_eq.tz Unit '(Pair -1 -1)' Unit
assert_fails $client run program $contract_dir/assert_eq.tz on storage Unit and input '(Pair 0 -1)'
assert_fails $client run script $contract_dir/assert_eq.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_dir/assert_neq.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run program $contract_dir/assert_neq.tz on storage Unit and input '(Pair -1 -1)'
assert_fails $client run script $contract_dir/assert_neq.tz on storage Unit and input '(Pair -1 -1)'
assert_storage $contract_dir/assert_lt.tz Unit '(Pair -1 0)' Unit
assert_fails $client run program $contract_dir/assert_lt.tz on storage Unit and input '(Pair 0 -1)'
assert_fails $client run program $contract_dir/assert_lt.tz on storage Unit and input '(Pair 0 0)'
assert_fails $client run script $contract_dir/assert_lt.tz on storage Unit and input '(Pair 0 -1)'
assert_fails $client run script $contract_dir/assert_lt.tz on storage Unit and input '(Pair 0 0)'
assert_storage $contract_dir/assert_le.tz Unit '(Pair 0 0)' Unit
assert_storage $contract_dir/assert_le.tz Unit '(Pair -1 0)' Unit
assert_fails $client run program $contract_dir/assert_le.tz on storage Unit and input '(Pair 0 -1)'
assert_fails $client run script $contract_dir/assert_le.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_dir/assert_gt.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run program $contract_dir/assert_gt.tz on storage Unit and input '(Pair -1 0)'
assert_fails $client run program $contract_dir/assert_gt.tz on storage Unit and input '(Pair 0 0)'
assert_fails $client run script $contract_dir/assert_gt.tz on storage Unit and input '(Pair -1 0)'
assert_fails $client run script $contract_dir/assert_gt.tz on storage Unit and input '(Pair 0 0)'
assert_storage $contract_dir/assert_ge.tz Unit '(Pair 0 0)' Unit
assert_storage $contract_dir/assert_ge.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run program $contract_dir/assert_ge.tz on storage Unit and input '(Pair -1 0)'
assert_fails $client run script $contract_dir/assert_ge.tz on storage Unit and input '(Pair -1 0)'
# ASSERT_CMP
assert_storage $contract_dir/assert_cmpeq.tz Unit '(Pair -1 -1)' Unit
assert_fails $client run program $contract_dir/assert_cmpeq.tz on storage Unit and input '(Pair 0 -1)'
assert_fails $client run script $contract_dir/assert_cmpeq.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_dir/assert_cmpeq.tz Unit '(Pair -1 -1)' Unit
assert_fails $client run program $contract_dir/assert_cmpeq.tz on storage Unit and input '(Pair 0 -1)'
assert_fails $client run script $contract_dir/assert_cmpeq.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_dir/assert_cmpneq.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run program $contract_dir/assert_cmpneq.tz on storage Unit and input '(Pair -1 -1)'
assert_fails $client run script $contract_dir/assert_cmpneq.tz on storage Unit and input '(Pair -1 -1)'
assert_storage $contract_dir/assert_cmplt.tz Unit '(Pair -1 0)' Unit
assert_fails $client run program $contract_dir/assert_cmplt.tz on storage Unit and input '(Pair 0 -1)'
assert_fails $client run program $contract_dir/assert_cmplt.tz on storage Unit and input '(Pair 0 0)'
assert_fails $client run script $contract_dir/assert_cmplt.tz on storage Unit and input '(Pair 0 -1)'
assert_fails $client run script $contract_dir/assert_cmplt.tz on storage Unit and input '(Pair 0 0)'
assert_storage $contract_dir/assert_cmple.tz Unit '(Pair 0 0)' Unit
assert_storage $contract_dir/assert_cmple.tz Unit '(Pair -1 0)' Unit
assert_fails $client run program $contract_dir/assert_cmple.tz on storage Unit and input '(Pair 0 -1)'
assert_fails $client run script $contract_dir/assert_cmple.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_dir/assert_cmpgt.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run program $contract_dir/assert_cmpgt.tz on storage Unit and input '(Pair -1 0)'
assert_fails $client run program $contract_dir/assert_cmpgt.tz on storage Unit and input '(Pair 0 0)'
assert_fails $client run script $contract_dir/assert_cmpgt.tz on storage Unit and input '(Pair -1 0)'
assert_fails $client run script $contract_dir/assert_cmpgt.tz on storage Unit and input '(Pair 0 0)'
assert_storage $contract_dir/assert_cmpge.tz Unit '(Pair 0 0)' Unit
assert_storage $contract_dir/assert_cmpge.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run program $contract_dir/assert_cmpge.tz on storage Unit and input '(Pair -1 0)'
assert_fails $client run script $contract_dir/assert_cmpge.tz on storage Unit and input '(Pair -1 0)'
# IF_SOME
assert_storage $contract_dir/if_some.tz '"?"' '(Some "hello")' '"hello"'
@ -297,7 +297,7 @@ assert_storage $contract_dir/if_some.tz '"?"' 'None' '""'
assert_storage $contract_dir/set_car.tz '(Pair "hello" 0)' '"world"' '(Pair "world" 0)'
assert_storage $contract_dir/set_car.tz '(Pair "hello" 0)' '"abc"' '(Pair "abc" 0)'
assert_storage $contract_dir/set_car.tz '(Pair "hello" 0)' '""' '(Pair "" 0)'
assert_fails $client run program $contract_dir/set_car.tz on storage '(Pair %wrong %field "hello" 0)' Unit and input '""'
assert_fails $client run script $contract_dir/set_car.tz on storage '(Pair %wrong %field "hello" 0)' Unit and input '""'
assert_storage $contract_dir/set_cdr.tz '(Pair "hello" 0)' '1' '(Pair "hello" 1)'
assert_storage $contract_dir/set_cdr.tz '(Pair "hello" 500)' '3' '(Pair "hello" 3)'
@ -314,11 +314,11 @@ assert_storage $contract_dir/map_caddaadr.tz \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 1000000) 4) 5))) 6)'
# Did the given key sign the string? (key is bootstrap1)
assert_success $client run program $contract_dir/check_signature.tz \
assert_success $client run script $contract_dir/check_signature.tz \
on storage '(Pair 0x011eb640b67c1859228a72730fae1a006bb94a999395dfb569e2776e9c1ae546376247f001343a1042f92082690f6aa2e6ed230df319b09767d9807ef3f8191f "hello")' \
and input '"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"'
assert_fails $client run program $contract_dir/check_signature.tz \
assert_fails $client run script $contract_dir/check_signature.tz \
on storage '(Pair 0x011eb640b67c1859228a72730fae1a006bb94a999395dfb569e2776e9c1ae546376247f001343a1042f92082690f6aa2e6ed230df319b09767d9807ef3f8191f "abcd")' \
and input '"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"'

View File

@ -82,7 +82,7 @@ run_contract_file () {
if [ ! -z "$4" ]; then
amount_flag="-amount $4"
fi
$client run program "$contract" on storage "$storage" and input "$input" $amount_flag
$client run script "$contract" on storage "$storage" and input "$input" $amount_flag
}
assert_storage () {
@ -122,7 +122,7 @@ contract_name_of_file () {
init_contract_from_file () {
local FILE="$1"
local NAME=$(contract_name_of_file "${FILE}")
$client remember program "${NAME}" "file:${FILE}"
$client remember script "${NAME}" "file:${FILE}"
}
bake () {

View File

@ -23,7 +23,7 @@ module Program = Client_aliases.Alias (struct
let of_source source =
return (Michelson_v1_parser.parse_toplevel source)
let to_source ({ Michelson_v1_parser.source }, _) = return source
let name = "program"
let name = "script"
end)
let print_errors (cctxt : #Client_context.printer) errs ~show_source ~parsed =
@ -32,7 +32,7 @@ let print_errors (cctxt : #Client_context.printer) errs ~show_source ~parsed =
~details:false
~show_source
~parsed) errs >>= fun () ->
cctxt#error "error running program" >>= fun () ->
cctxt#error "error running script" >>= fun () ->
return ()
let print_big_map_diff ppf = function
@ -181,4 +181,4 @@ let print_typecheck_result
~details: show_types
~show_source:print_source_on_error
~parsed:program) errs >>= fun () ->
cctxt#error "ill-typed program"
cctxt#error "ill-typed script"

View File

@ -10,8 +10,8 @@
open Proto_alpha
let group =
{ Clic.name = "programs" ;
title = "Commands for managing the library of known programs" }
{ Clic.name = "scripts" ;
title = "Commands for managing the library of known scripts" }
open Tezos_micheline
open Client_proto_programs
@ -76,17 +76,17 @@ let commands () =
| None -> failwith "Not given a valid signature") in
[
command ~group ~desc: "Lists all programs in the library."
command ~group ~desc: "Lists all scripts in the library."
no_options
(fixed [ "list" ; "known" ; "programs" ])
(fixed [ "list" ; "known" ; "scripts" ])
(fun () (cctxt : Proto_alpha.full) ->
Program.load cctxt >>=? fun list ->
Lwt_list.iter_s (fun (n, _) -> cctxt#message "%s" n) list >>= fun () ->
return ()) ;
command ~group ~desc: "Add a program to the library."
command ~group ~desc: "Add a script to the library."
(args1 (Program.force_switch ()))
(prefixes [ "remember" ; "program" ]
(prefixes [ "remember" ; "script" ]
@@ Program.fresh_alias_param
@@ Program.source_param
@@ stop)
@ -94,16 +94,16 @@ let commands () =
Program.of_fresh cctxt force name >>=? fun name ->
Program.add ~force cctxt name hash) ;
command ~group ~desc: "Remove a program from the library."
command ~group ~desc: "Remove a script from the library."
no_options
(prefixes [ "forget" ; "program" ]
(prefixes [ "forget" ; "script" ]
@@ Program.alias_param
@@ stop)
(fun () (name, _) cctxt -> Program.del cctxt name) ;
command ~group ~desc: "Display a program from the library."
command ~group ~desc: "Display a script from the library."
no_options
(prefixes [ "show" ; "known" ; "program" ]
(prefixes [ "show" ; "known" ; "script" ]
@@ Program.alias_param
@@ stop)
(fun () (_, program) (cctxt : Proto_alpha.full) ->
@ -111,9 +111,9 @@ let commands () =
cctxt#message "%s\n" source >>= fun () ->
return ()) ;
command ~group ~desc: "Ask the node to run a program."
command ~group ~desc: "Ask the node to run a script."
(args3 trace_stack_switch amount_arg no_print_source_flag)
(prefixes [ "run" ; "program" ]
(prefixes [ "run" ; "script" ]
@@ Program.source_param
@@ prefixes [ "on" ; "storage" ]
@@ Clic.param ~name:"storage" ~desc:"the storage data"
@ -131,9 +131,9 @@ let commands () =
else
run cctxt cctxt#block ~amount ~program ~storage ~input () >>= fun res ->
print_run_result cctxt ~show_source ~parsed:program res)) ;
command ~group ~desc: "Ask the node to typecheck a program."
command ~group ~desc: "Ask the node to typecheck a script."
(args4 show_types_switch emacs_mode_switch no_print_source_flag custom_gas_flag)
(prefixes [ "typecheck" ; "program" ]
(prefixes [ "typecheck" ; "script" ]
@@ Program.source_param
@@ stop)
(fun (show_types, emacs_mode, no_print_source, original_gas) program cctxt ->