Add CameLIGO key_hash test

This commit is contained in:
John David Pressman 2020-01-16 21:37:29 -08:00
parent 4ee3a29a34
commit 4fcfa3df8f
2 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,5 @@
let check_hash_key (kh1, k2: key_hash * key) : bool * key_hash =
let kh2 : key_hash = Crypto.hash_key k2 in
if kh1 = kh2
then (true, kh2)
else (false, kh2)

View File

@ -1901,6 +1901,17 @@ let key_hash () : unit result =
let%bind () = expect_eq program "check_hash_key" make_input make_expected in let%bind () = expect_eq program "check_hash_key" make_input make_expected in
ok () ok ()
let key_hash_mligo () : 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 = mtype_file "./contracts/key_hash.mligo" 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 curry () : unit result =
let%bind program = mtype_file "./contracts/curry.mligo" in let%bind program = mtype_file "./contracts/curry.mligo" in
let%bind () = let%bind () =
@ -2035,6 +2046,7 @@ let main = test_suite "Integration (End to End)" [
test "bytes unpack (mligo)" bytes_unpack_mligo ; test "bytes unpack (mligo)" bytes_unpack_mligo ;
test "bytes unpack (religo)" bytes_unpack_religo ; test "bytes unpack (religo)" bytes_unpack_religo ;
test "key hash" key_hash ; test "key hash" key_hash ;
test "key hash (mligo)" key_hash_mligo ;
test "chain id" chain_id ; test "chain id" chain_id ;
test "type alias" type_alias ; test "type alias" type_alias ;
test "function" function_ ; test "function" function_ ;