From 4ee3a29a349f2094cb75b32788f533d863fcad4a Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Thu, 16 Jan 2020 20:59:26 -0800 Subject: [PATCH] Enable CameLIGO bytes_unpack test and add one for ReasonLIGO --- src/test/contracts/bytes_unpack.religo | 14 ++++++++++++++ src/test/integration_tests.ml | 13 ++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/test/contracts/bytes_unpack.religo diff --git a/src/test/contracts/bytes_unpack.religo b/src/test/contracts/bytes_unpack.religo new file mode 100644 index 000000000..86b291ecc --- /dev/null +++ b/src/test/contracts/bytes_unpack.religo @@ -0,0 +1,14 @@ +let id_string = (p: string) : option(string) => { + let packed : bytes = Bytes.pack(p); + ((Bytes.unpack(packed)): option(string)); +}; + +let id_int = (p: int) : option(int) => { + let packed: bytes = Bytes.pack(p); + ((Bytes.unpack(packed)): option(int)); +}; + +let id_address = (p: address) : option(address) => { + let packed: bytes = Bytes.pack(p); + ((Bytes.unpack(packed)): option(address)); +}; diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 83647bb12..375f59423 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -1978,6 +1978,16 @@ let bytes_unpack_mligo () : unit result = let%bind () = expect_eq program "id_address" (e_address addr) (e_some (e_address addr)) in ok () +let bytes_unpack_religo () : unit result = + let%bind program = retype_file "./contracts/bytes_unpack.religo" in + let%bind () = expect_eq program "id_string" (e_string "teststring") (e_some (e_string "teststring")) in + let%bind () = expect_eq program "id_int" (e_int 42) (e_some (e_int 42)) in + let open Proto_alpha_utils.Memory_proto_alpha in + let addr = Protocol.Alpha_context.Contract.to_b58check @@ + (List.nth dummy_environment.identities 0).implicit_contract in + let%bind () = expect_eq program "id_address" (e_address addr) (e_some (e_address addr)) in + ok () + let empty_case () : unit result = let%bind program = type_file "./contracts/empty_case.ligo" in let%bind () = @@ -2022,7 +2032,8 @@ let empty_case_religo () : unit result = let main = test_suite "Integration (End to End)" [ test "bytes unpack" bytes_unpack ; - test "bytes unpack (mligo)" bytes_unpack ; + test "bytes unpack (mligo)" bytes_unpack_mligo ; + test "bytes unpack (religo)" bytes_unpack_religo ; test "key hash" key_hash ; test "chain id" chain_id ; test "type alias" type_alias ;