From 44ff5d580d0191a44f442ce43a260ec4e2230448 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Wed, 19 Feb 2020 16:10:50 +0100 Subject: [PATCH] Allow using top level variables defined in source code in dry-run PARAMETER and STORAGE --- src/bin/cli.ml | 2 +- src/bin/expect_tests/contract_tests.ml | 7 ++++++- src/test/contracts/super-counter.mligo | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bin/cli.ml b/src/bin/cli.ml index 92716d380..f9b6321e5 100644 --- a/src/bin/cli.ml +++ b/src/bin/cli.ml @@ -327,7 +327,7 @@ let dry_run = let%bind simplified = Compile.Of_source.compile_contract_input storage input v_syntax in let%bind typed,_ = Compile.Of_simplified.compile_expression ~env ~state simplified in let%bind mini_c = Compile.Of_typed.compile_expression typed in - let%bind compiled_params = Compile.Of_mini_c.compile_expression mini_c in + let%bind compiled_params = Compile.Of_mini_c.aggregate_and_compile_expression mini_c_prg mini_c in let%bind args_michelson = Run.evaluate_expression compiled_params.expr compiled_params.expr_ty in let%bind options = Run.make_dry_run_options {predecessor_timestamp ; amount ; sender ; source } in diff --git a/src/bin/expect_tests/contract_tests.ml b/src/bin/expect_tests/contract_tests.ml index 2a3c4bd8d..cfc6f0490 100644 --- a/src/bin/expect_tests/contract_tests.ml +++ b/src/bin/expect_tests/contract_tests.ml @@ -1136,4 +1136,9 @@ let%expect_test _ = [%expect {| { parameter int ; storage (pair (map %one key_hash nat) (big_map %two key_hash bool)) ; - code { DUP ; CDR ; NIL operation ; PAIR ; DIP { DROP } } } |}] \ No newline at end of file + code { DUP ; CDR ; NIL operation ; PAIR ; DIP { DROP } } } |}] + +let%expect_test _ = + run_ligo_good [ "dry-run" ; contract "super-counter.mligo" ; "main" ; "test_param" ; "test_storage" ] ; + [%expect {| + ( list[] , 3 ) |}] \ No newline at end of file diff --git a/src/test/contracts/super-counter.mligo b/src/test/contracts/super-counter.mligo index 613d9b29b..dc00c9567 100644 --- a/src/test/contracts/super-counter.mligo +++ b/src/test/contracts/super-counter.mligo @@ -2,6 +2,9 @@ type action = | Increment of int | Decrement of int +let test_param = Increment(1) +let test_storage = 2 + let main (ps : action * int) : (operation list * int) = let storage = match ps.0 with