From 411c17eb99043d3665ceffbeeed6e08020bb4199 Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Thu, 16 Jan 2020 21:45:40 -0800 Subject: [PATCH] Add ReasonLIGO version of key_hash test --- src/test/contracts/key_hash.religo | 10 ++++++++++ src/test/integration_tests.ml | 12 ++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/test/contracts/key_hash.religo diff --git a/src/test/contracts/key_hash.religo b/src/test/contracts/key_hash.religo new file mode 100644 index 000000000..f3b8e8976 --- /dev/null +++ b/src/test/contracts/key_hash.religo @@ -0,0 +1,10 @@ +let check_hash_key = (kh1_k2: (key_hash, key)) : (bool, key_hash) => { + let kh1, k2 = kh1_k2; + let kh2 : key_hash = Crypto.hash_key(k2); + if (kh1 == kh2) { + (true, kh2); + } + else { + (false, kh2); + } +}; diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 98074e608..7d5b909c5 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -1912,6 +1912,17 @@ let key_hash_mligo () : unit result = let%bind () = expect_eq program "check_hash_key" make_input make_expected in ok () +let key_hash_religo () : unit result = + let open Tezos_crypto in + let (raw_pkh,raw_pk,_) = Signature.generate_key () in + let pkh_str = Signature.Public_key_hash.to_b58check raw_pkh in + let pk_str = Signature.Public_key.to_b58check raw_pk in + let%bind program = retype_file "./contracts/key_hash.religo" in + let make_input = e_pair (e_key_hash pkh_str) (e_key pk_str) in + let make_expected = e_pair (e_bool true) (e_key_hash pkh_str) in + let%bind () = expect_eq program "check_hash_key" make_input make_expected in + ok () + let curry () : unit result = let%bind program = mtype_file "./contracts/curry.mligo" in let%bind () = @@ -2047,6 +2058,7 @@ let main = test_suite "Integration (End to End)" [ test "bytes unpack (religo)" bytes_unpack_religo ; test "key hash" key_hash ; test "key hash (mligo)" key_hash_mligo ; + test "key hash (religo)" key_hash_religo ; test "chain id" chain_id ; test "type alias" type_alias ; test "function" function_ ;