From eb4336b0e7337e55bec3595602981b8e2be54cb7 Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Fri, 17 Jan 2020 01:50:06 -0800 Subject: [PATCH] Add PascaLIGO CHECK_SIGNATURE test to suite --- src/test/contracts/check_signature.ligo | 2 ++ src/test/integration_tests.ml | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/test/contracts/check_signature.ligo diff --git a/src/test/contracts/check_signature.ligo b/src/test/contracts/check_signature.ligo new file mode 100644 index 000000000..231b726ea --- /dev/null +++ b/src/test/contracts/check_signature.ligo @@ -0,0 +1,2 @@ +function check_signature (const pk: key; const signed: signature; const msg: bytes) : bool is + crypto_check(pk, signed, msg) diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 7d5b909c5..3daec1887 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -1923,6 +1923,19 @@ let key_hash_religo () : unit result = let%bind () = expect_eq program "check_hash_key" make_input make_expected in ok () +let check_signature () : unit result = + let open Tezos_crypto in + let (_, raw_pk, sk) = Signature.generate_key () in + let pk_str = Signature.Public_key.to_b58check raw_pk in + let signed = Signature.sign sk (Bytes.of_string "hello world") in + let%bind program = type_file "./contracts/check_signature.ligo" in + let make_input = e_tuple [e_key pk_str ; + e_signature (Signature.to_b58check signed) ; + e_bytes_ofbytes (Bytes.of_string "hello world")] in + let make_expected = e_bool true in + let%bind () = expect_eq program "check_signature" make_input make_expected in + ok () + let curry () : unit result = let%bind program = mtype_file "./contracts/curry.mligo" in let%bind () = @@ -2059,6 +2072,7 @@ let main = test_suite "Integration (End to End)" [ test "key hash" key_hash ; test "key hash (mligo)" key_hash_mligo ; test "key hash (religo)" key_hash_religo ; + test "check signature" check_signature ; test "chain id" chain_id ; test "type alias" type_alias ; test "function" function_ ;