From 20285f2b9eb024d3119e88c054d90daec1b8fc20 Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Mon, 16 Dec 2019 16:26:39 -0800 Subject: [PATCH] Add broken set_delegate test to LIGO, get to typer error --- src/passes/operators/operators.ml | 1 + src/stages/common/PP.ml | 1 + src/stages/common/types.ml | 1 + src/test/contracts/set_delegate.ligo | 6 ++++++ src/test/integration_tests.ml | 9 +++++++++ 5 files changed, 18 insertions(+) create mode 100644 src/test/contracts/set_delegate.ligo diff --git a/src/passes/operators/operators.ml b/src/passes/operators/operators.ml index 3ac7a0959..cc24882f4 100644 --- a/src/passes/operators/operators.ml +++ b/src/passes/operators/operators.ml @@ -131,6 +131,7 @@ module Simplify = struct | "address" -> ok C_ADDRESS | "self_address" -> ok C_SELF_ADDRESS | "implicit_account"-> ok C_IMPLICIT_ACCOUNT + | "set_delegate" -> ok C_SET_DELEGATE | _ -> simple_fail "Not a PascaLIGO constant" let type_constants = type_constants diff --git a/src/stages/common/PP.ml b/src/stages/common/PP.ml index e32e9dd52..c2f6da860 100644 --- a/src/stages/common/PP.ml +++ b/src/stages/common/PP.ml @@ -116,6 +116,7 @@ let constant ppf : constant -> unit = function | C_ADDRESS -> fprintf ppf "ADDRESS" | C_SELF_ADDRESS -> fprintf ppf "SELF_ADDRESS" | C_IMPLICIT_ACCOUNT -> fprintf ppf "IMPLICIT_ACCOUNT" + | C_SET_DELEGATE -> fprintf ppf "SET_DELEGATE" | C_STEPS_TO_QUOTA -> fprintf ppf "STEPS_TO_QUOTA" let cmap_sep value sep ppf m = diff --git a/src/stages/common/types.ml b/src/stages/common/types.ml index 29ceee5d5..b25eb80a5 100644 --- a/src/stages/common/types.ml +++ b/src/stages/common/types.ml @@ -232,4 +232,5 @@ type constant = | C_ADDRESS | C_SELF_ADDRESS | C_IMPLICIT_ACCOUNT + | C_SET_DELEGATE | C_STEPS_TO_QUOTA diff --git a/src/test/contracts/set_delegate.ligo b/src/test/contracts/set_delegate.ligo new file mode 100644 index 000000000..68e541861 --- /dev/null +++ b/src/test/contracts/set_delegate.ligo @@ -0,0 +1,6 @@ +function main (const p: key_hash) : list(operation) is + begin + set_delegate(p) ; + const dummy: list(operation) = nil; + end with dummy + diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 921a6a376..9d772b736 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -1756,6 +1756,14 @@ let key_hash () : unit result = let%bind () = expect_eq program "check_hash_key" make_input make_expected in ok () +let set_delegate () : unit result = + let open Tezos_crypto in + let (raw_pkh,_,_) = Signature.generate_key () in + let pkh_str = Signature.Public_key_hash.to_b58check raw_pkh in + let%bind program = type_file "./contracts/set_delegate.ligo" in + let%bind () = expect_eq program "main" (e_string pkh_str) (e_typed_list [] t_operation) + in ok () + let main = test_suite "Integration (End to End)" [ test "key hash" key_hash ; test "chain id" chain_id ; @@ -1883,6 +1891,7 @@ let main = test_suite "Integration (End to End)" [ test "implicit account" implicit_account ; test "implicit account (mligo)" implicit_account_mligo ; test "implicit account (religo)" implicit_account_religo ; + test "set delegate" set_delegate ; test "is_nat" is_nat ; test "is_nat (mligo)" is_nat_mligo ; test "is_nat (religo)" is_nat_religo ;