From 6dfd2dac32a294e8d6ee69cd06198d25d964c7c1 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Wulfman Date: Thu, 12 Mar 2020 23:24:10 +0100 Subject: [PATCH] test passed --- src/test/coase_tests.ml | 11 ++++++----- src/test/hash_lock_tests.ml | 11 ++++++----- src/test/id_tests.ml | 7 ++++--- src/test/integration_tests.ml | 12 +++++++++--- src/test/md_file_tests.ml | 4 +++- src/test/multisig_tests.ml | 18 ++++++++++-------- src/test/multisig_v2_tests.ml | 13 +++++++------ src/test/pledge_tests.ml | 11 ++++++----- src/test/replaceable_id_tests.ml | 7 ++++--- src/test/time_lock_repeat_tests.ml | 7 ++++--- src/test/time_lock_tests.ml | 7 ++++--- src/test/vote_tests.ml | 4 +++- 12 files changed, 66 insertions(+), 46 deletions(-) diff --git a/src/test/coase_tests.ml b/src/test/coase_tests.ml index 5df29091f..b773764f9 100644 --- a/src/test/coase_tests.ml +++ b/src/test/coase_tests.ml @@ -4,7 +4,9 @@ open Trace open Test_helpers let type_file f = - let%bind simplified = Ligo.Compile.Of_source.compile f (Syntax_name "pascaligo") in + let%bind abstracted = Ligo.Compile.Of_source.compile f (Syntax_name "pascaligo") in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,state = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in ok @@ (typed,state) @@ -20,10 +22,9 @@ let get_program = ) let compile_main () = - let%bind simplified = Ligo.Compile.Of_source.compile "./contracts/coase.ligo" (Syntax_name "pascaligo") in - let%bind typed_prg,_ = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in - let%bind mini_c_prg = Ligo.Compile.Of_typed.compile typed_prg in - let%bind michelson_prg = Ligo.Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg "main" in + let%bind typed_prg = get_program () in + let%bind mini_c_prg = Ligo.Compile.Of_typed.compile typed_prg in + let%bind michelson_prg = Ligo.Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg "main" in let%bind (_contract: Tezos_utils.Michelson.michelson) = (* fails if the given entry point is not a valid contract *) Ligo.Compile.Of_michelson.build_contract michelson_prg in diff --git a/src/test/hash_lock_tests.ml b/src/test/hash_lock_tests.ml index 7a6db1ea8..9ebfe3618 100644 --- a/src/test/hash_lock_tests.ml +++ b/src/test/hash_lock_tests.ml @@ -3,7 +3,9 @@ open Test_helpers open Ast_simplified let type_file f = - let%bind simplified = Ligo.Compile.Of_source.compile f (Syntax_name "cameligo") in + let%bind abstracted = Ligo.Compile.Of_source.compile f (Syntax_name "cameligo") in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,state = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in ok @@ (typed,state) @@ -18,10 +20,9 @@ let get_program = ) let compile_main () = - let%bind simplified = Ligo.Compile.Of_source.compile "./contracts/hashlock.mligo" (Syntax_name "cameligo") in - let%bind typed_prg,_ = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in - let%bind mini_c_prg = Ligo.Compile.Of_typed.compile typed_prg in - let%bind michelson_prg = Ligo.Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg "main" in + let%bind typed_prg,_ = get_program () in + let%bind mini_c_prg = Ligo.Compile.Of_typed.compile typed_prg in + let%bind michelson_prg = Ligo.Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg "main" in let%bind (_contract: Tezos_utils.Michelson.michelson) = (* fails if the given entry point is not a valid contract *) Ligo.Compile.Of_michelson.build_contract michelson_prg in diff --git a/src/test/id_tests.ml b/src/test/id_tests.ml index 294cd08ff..bedc465db 100644 --- a/src/test/id_tests.ml +++ b/src/test/id_tests.ml @@ -4,7 +4,9 @@ open Ast_simplified let mtype_file f = - let%bind simplified = Ligo.Compile.Of_source.compile f (Syntax_name "cameligo") in + let%bind abstracted = Ligo.Compile.Of_source.compile f (Syntax_name "cameligo") in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,state = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in ok (typed,state) @@ -19,8 +21,7 @@ let get_program = ) let compile_main () = - let%bind simplified = Ligo.Compile.Of_source.compile "./contracts/id.mligo" (Syntax_name "cameligo") in - let%bind typed_prg,_ = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in + let%bind typed_prg,_ = get_program () in let%bind mini_c_prg = Ligo.Compile.Of_typed.compile typed_prg in let%bind michelson_prg = Ligo.Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg "main" in let%bind (_contract: Tezos_utils.Michelson.michelson) = diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 9c17f2479..9fcb5f261 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -4,18 +4,24 @@ open Test_helpers open Ast_simplified.Combinators let retype_file f = - let%bind simplified = Ligo.Compile.Of_source.compile f (Syntax_name "reasonligo") in + let%bind abstracted = Ligo.Compile.Of_source.compile f (Syntax_name "reasonligo") in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,state = Ligo.Compile.Of_simplified.compile Env simplified in let () = Typer.Solver.discard_state state in let () = Typer.Solver.discard_state state in ok typed let mtype_file f = - let%bind simplified = Ligo.Compile.Of_source.compile f (Syntax_name "cameligo") in + let%bind abstracted = Ligo.Compile.Of_source.compile f (Syntax_name "cameligo") in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,state = Ligo.Compile.Of_simplified.compile Env simplified in let () = Typer.Solver.discard_state state in ok typed let type_file f = - let%bind simplified = Ligo.Compile.Of_source.compile f (Syntax_name "pascaligo") in + let%bind abstracted = Ligo.Compile.Of_source.compile f (Syntax_name "pascaligo") in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,state = Ligo.Compile.Of_simplified.compile Env simplified in let () = Typer.Solver.discard_state state in ok typed diff --git a/src/test/md_file_tests.ml b/src/test/md_file_tests.ml index 14748f9c8..042c6ebaa 100644 --- a/src/test/md_file_tests.ml +++ b/src/test/md_file_tests.ml @@ -68,7 +68,9 @@ let compile_groups _filename grp_list = (fun ((s,grp),contents) -> trace (failed_to_compile_md_file _filename (s,grp,contents)) @@ let%bind v_syntax = Compile.Helpers.syntax_to_variant (Syntax_name s) None in - let%bind simplified = Compile.Of_source.compile_string contents v_syntax in + let%bind abstracted = Compile.Of_source.compile_string contents v_syntax in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,_ = Compile.Of_simplified.compile Env simplified in let%bind mini_c = Compile.Of_typed.compile typed in bind_map_list diff --git a/src/test/multisig_tests.ml b/src/test/multisig_tests.ml index 704171e01..0866302c0 100644 --- a/src/test/multisig_tests.ml +++ b/src/test/multisig_tests.ml @@ -6,7 +6,9 @@ let mfile = "./contracts/multisig.mligo" let refile = "./contracts/multisig.religo" let type_file f s = - let%bind simplified = Ligo.Compile.Of_source.compile f (Syntax_name s) in + let%bind abstracted = Ligo.Compile.Of_source.compile f (Syntax_name s) in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,state = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in ok @@ (typed,state) @@ -175,12 +177,12 @@ let main = test_suite "Multisig" [ test "valid_2_of_3 (mligo)" (valid_2_of_3 mfile "cameligo"); test "invalid_3_of_3 (mligo)" (invalid_3_of_3 mfile "cameligo"); test "not_enough_2_of_3 (mligo)" (not_enough_2_of_3 mfile "cameligo"); - test "compile (religo)" (compile_main refile "reasonligo"); + test "compile (religo)" (compile_main refile "reasonligo"); test "unmatching_counter (religo)" (unmatching_counter refile "reasonligo"); - test "valid_1_of_1 (religo)" (valid_1_of_1 refile "reasonligo"); - test "invalid_1_of_1 (religo)" (invalid_1_of_1 refile "reasonligo"); - test "not_enough_signature (religo)" (not_enough_1_of_2 refile "reasonligo"); - test "valid_2_of_3 (religo)" (valid_2_of_3 refile "reasonligo"); - test "invalid_3_of_3 (religo)" (invalid_3_of_3 refile "reasonligo"); - test "not_enough_2_of_3 (religo)" (not_enough_2_of_3 refile "reasonligo"); + test "valid_1_of_1 (religo)" (valid_1_of_1 refile "reasonligo"); + test "invalid_1_of_1 (religo)" (invalid_1_of_1 refile "reasonligo"); + test "not_enough_signature (religo)" (not_enough_1_of_2 refile "reasonligo"); + test "valid_2_of_3 (religo)" (valid_2_of_3 refile "reasonligo"); + test "invalid_3_of_3 (religo)" (invalid_3_of_3 refile "reasonligo"); + test "not_enough_2_of_3 (religo)" (not_enough_2_of_3 refile "reasonligo"); ] diff --git a/src/test/multisig_v2_tests.ml b/src/test/multisig_v2_tests.ml index 391be83d2..01248c2dd 100644 --- a/src/test/multisig_v2_tests.ml +++ b/src/test/multisig_v2_tests.ml @@ -2,7 +2,9 @@ open Trace open Test_helpers let type_file f = - let%bind simplified = Ligo.Compile.Of_source.compile f (Syntax_name "pascaligo") in + let%bind abstracted = Ligo.Compile.Of_source.compile f (Syntax_name "pascaligo") in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,state = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in ok @@ (typed,state) @@ -17,10 +19,9 @@ let get_program = ) let compile_main () = - let%bind simplified = Ligo.Compile.Of_source.compile "./contracts/multisig-v2.ligo" (Syntax_name "pascaligo") in - let%bind typed_prg,_ = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in - let%bind mini_c_prg = Ligo.Compile.Of_typed.compile typed_prg in - let%bind michelson_prg = Ligo.Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg "main" in + let%bind typed_prg,_ = get_program () in + let%bind mini_c_prg = Ligo.Compile.Of_typed.compile typed_prg in + let%bind michelson_prg = Ligo.Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg "main" in let%bind (_contract: Tezos_utils.Michelson.michelson) = (* fails if the given entry point is not a valid contract *) Ligo.Compile.Of_michelson.build_contract michelson_prg in @@ -35,7 +36,7 @@ let empty_message = e_lambda (Var.of_name "arguments") empty_op_list let empty_message2 = e_lambda (Var.of_name "arguments") (Some t_bytes) (Some (t_list t_operation)) - ( e_let_in ((Var.of_name "foo"),Some t_unit) false false (e_unit ()) empty_op_list) + ( e_let_in ((Var.of_name "foo"),Some t_unit) false (e_unit ()) empty_op_list) let send_param msg = e_constructor "Send" msg let withdraw_param = e_constructor "Withdraw" empty_message diff --git a/src/test/pledge_tests.ml b/src/test/pledge_tests.ml index d6af4f369..7d8d0abcf 100644 --- a/src/test/pledge_tests.ml +++ b/src/test/pledge_tests.ml @@ -4,7 +4,9 @@ open Ast_simplified let retype_file f = - let%bind simplified = Ligo.Compile.Of_source.compile f (Syntax_name "reasonligo") in + let%bind abstracted = Ligo.Compile.Of_source.compile f (Syntax_name "reasonligo") in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,state = Ligo.Compile.Of_simplified.compile Env simplified in ok (typed,state) @@ -19,10 +21,9 @@ let get_program = ) let compile_main () = - let%bind simplified = Ligo.Compile.Of_source.compile "./contracts/pledge.religo" (Syntax_name "reasonligo") in - let%bind typed_prg,_ = Ligo.Compile.Of_simplified.compile Env simplified in - let%bind mini_c_prg = Ligo.Compile.Of_typed.compile typed_prg in - let%bind michelson_prg = Ligo.Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg "main" in + let%bind typed_prg,_ = get_program () in + let%bind mini_c_prg = Ligo.Compile.Of_typed.compile typed_prg in + let%bind michelson_prg = Ligo.Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg "main" in let%bind (_contract: Tezos_utils.Michelson.michelson) = (* fails if the given entry point is not a valid contract *) Ligo.Compile.Of_michelson.build_contract michelson_prg in diff --git a/src/test/replaceable_id_tests.ml b/src/test/replaceable_id_tests.ml index 60bcb203e..b3623025c 100644 --- a/src/test/replaceable_id_tests.ml +++ b/src/test/replaceable_id_tests.ml @@ -2,7 +2,9 @@ open Trace open Test_helpers let type_file f = - let%bind simplified = Ligo.Compile.Of_source.compile f (Syntax_name "pascaligo") in + let%bind abstracted = Ligo.Compile.Of_source.compile f (Syntax_name "pascaligo") in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,state = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in ok @@ (typed,state) @@ -17,8 +19,7 @@ let get_program = ) let compile_main () = - let%bind simplified = Ligo.Compile.Of_source.compile "./contracts/replaceable_id.ligo" (Syntax_name "pascaligo") in - let%bind typed_prg,_ = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in + let%bind typed_prg,_ = get_program () in let%bind mini_c_prg = Ligo.Compile.Of_typed.compile typed_prg in let%bind michelson_prg = Ligo.Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg "main" in let%bind (_contract: Tezos_utils.Michelson.michelson) = diff --git a/src/test/time_lock_repeat_tests.ml b/src/test/time_lock_repeat_tests.ml index b5a3f7427..35c70cfa3 100644 --- a/src/test/time_lock_repeat_tests.ml +++ b/src/test/time_lock_repeat_tests.ml @@ -3,7 +3,9 @@ open Test_helpers open Ast_simplified let type_file f = - let%bind simplified = Ligo.Compile.Of_source.compile f (Syntax_name "cameligo") in + let%bind abstracted = Ligo.Compile.Of_source.compile f (Syntax_name "cameligo") in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,state = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in ok @@ (typed,state) @@ -18,8 +20,7 @@ let get_program = ) let compile_main () = - let%bind simplified = Ligo.Compile.Of_source.compile "./contracts/timelock_repeat.mligo" (Syntax_name "cameligo") in - let%bind typed_prg,_ = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in + let%bind typed_prg,_ = type_file "./contracts/timelock_repeat.mligo" in let%bind mini_c_prg = Ligo.Compile.Of_typed.compile typed_prg in let%bind michelson_prg = Ligo.Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg "main" in let%bind (_contract: Tezos_utils.Michelson.michelson) = diff --git a/src/test/time_lock_tests.ml b/src/test/time_lock_tests.ml index eb3001f49..d5247b3cd 100644 --- a/src/test/time_lock_tests.ml +++ b/src/test/time_lock_tests.ml @@ -2,7 +2,9 @@ open Trace open Test_helpers let type_file f = - let%bind simplified = Ligo.Compile.Of_source.compile f (Syntax_name "pascaligo") in + let%bind abstracted = Ligo.Compile.Of_source.compile f (Syntax_name "pascaligo") in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,state = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in ok @@ (typed,state) @@ -17,8 +19,7 @@ let get_program = ) let compile_main () = - let%bind simplified = Ligo.Compile.Of_source.compile "./contracts/time-lock.ligo" (Syntax_name "pascaligo") in - let%bind typed_prg,_ = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in + let%bind typed_prg,_ = type_file "./contracts/time-lock.ligo" in let%bind mini_c_prg = Ligo.Compile.Of_typed.compile typed_prg in let%bind michelson_prg = Ligo.Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg "main" in let%bind (_contract: Tezos_utils.Michelson.michelson) = diff --git a/src/test/vote_tests.ml b/src/test/vote_tests.ml index ddc3d620d..c572ce340 100644 --- a/src/test/vote_tests.ml +++ b/src/test/vote_tests.ml @@ -2,7 +2,9 @@ open Trace open Test_helpers let type_file f = - let%bind simplified = Ligo.Compile.Of_source.compile f (Syntax_name "cameligo") in + let%bind abstracted = Ligo.Compile.Of_source.compile f (Syntax_name "cameligo") in + let%bind complex = Ligo.Compile.Of_abstracted.compile abstracted in + let%bind simplified = Ligo.Compile.Of_complex.compile complex in let%bind typed,state = Ligo.Compile.Of_simplified.compile (Contract "main") simplified in ok @@ (typed,state)