Enable CameLIGO bytes_unpack test and add one for ReasonLIGO

This commit is contained in:
John David Pressman 2020-01-16 20:59:26 -08:00
parent ca1caf2e61
commit 4ee3a29a34
2 changed files with 26 additions and 1 deletions

View File

@ -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));
};

View File

@ -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 ;