Add bytes_unpack test for CameLIGO

This commit is contained in:
John David Pressman 2020-01-16 20:27:50 -08:00
parent 6ce1ca4fcd
commit ca1caf2e61
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,11 @@
let id_string (p: string) : string option =
let packed: bytes = Bytes.pack p in
((Bytes.unpack packed): string option)
let id_int (p: int) : int option =
let packed: bytes = Bytes.pack p in
((Bytes.unpack packed): int option)
let id_address (p: address) : address option =
let packed: bytes = Bytes.pack p in
((Bytes.unpack packed): address option)

View File

@ -1968,6 +1968,16 @@ let bytes_unpack () : unit result =
let%bind () = expect_eq program "id_address" (e_address addr) (e_some (e_address addr)) in let%bind () = expect_eq program "id_address" (e_address addr) (e_some (e_address addr)) in
ok () ok ()
let bytes_unpack_mligo () : unit result =
let%bind program = mtype_file "./contracts/bytes_unpack.mligo" 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 empty_case () : unit result =
let%bind program = type_file "./contracts/empty_case.ligo" in let%bind program = type_file "./contracts/empty_case.ligo" in
let%bind () = let%bind () =
@ -2012,6 +2022,7 @@ let empty_case_religo () : unit result =
let main = test_suite "Integration (End to End)" [ let main = test_suite "Integration (End to End)" [
test "bytes unpack" bytes_unpack ; test "bytes unpack" bytes_unpack ;
test "bytes unpack (mligo)" bytes_unpack ;
test "key hash" key_hash ; test "key hash" key_hash ;
test "chain id" chain_id ; test "chain id" chain_id ;
test "type alias" type_alias ; test "type alias" type_alias ;