Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • dan0196/ligo
  • ligolang/ligo
  • maht0rz/ligo
  • JD-P/ligo
  • governancy/ligo
  • renovatorruler/ligo
  • dailambda/ligo
  • jevonearth/ligo
  • mbykovskyy_ecadlabs/ligo
  • opt9/ligo
  • arvidnl/ligo
  • jpic/ligo
  • juztin/ligo
  • steakandbake/ligo
  • mark-o-robson/ligo
  • simon138/ligo
  • nmangan/ligo
  • edmondlee/ligo
  • technomad21c/ligo
  • diogo.machado/ligo
  • kkirka/ligo
  • nobrakal/ligo
  • roxane3/ligo
  • GImbrailo/ligo
  • syuhei176/ligo
  • mjgajda/ligo
  • sanityinc/ligo
  • molllyn1/ligo
  • ulrikstrid/ligo
  • prometheansacrifice/ligo
  • nicolas.van.phan/ligo
  • ryujh21h/ligo
  • rishabhkeshan/ligo
  • amitcz/ligo
  • jobjo/ligo
  • deryyy/ligo
  • my8bit/ligo
  • daachi/ligo
  • elmorg/ligo
  • a.kumar4/ligo
  • dheavy/ligo
  • konchunas/ligo
  • ggichuru.dev/ligo
  • steven_j/ligo
  • arguiot/ligo
  • digitea00/ligo
  • melwyn95/ligo
  • chrispinnock/ligo
  • clarus1/ligo
  • patrickferris/ligo
  • caaatisgood/ligo
  • karoshibee/ligo-kbee
  • arguil/ligo
  • benjamin.fuentes/ligo
  • Dayveed117/ligo
  • timothymcmackin/ligo
  • shubham-kumar/ligo
  • bfamchon1/ligo
  • mavryk-network/ligo
  • int-index/ligo
60 results
Show changes
Commits on Source (6)
Showing
with 1327 additions and 10439 deletions
author: alistair.obrien
description: "\\n\\nfix(interpreter): allow performing operations on tickets in tests\\n\\nFor instance, the following demonstrates the use of `create_ticket` and `read_ticket`,\\nwhich previously resulted in an error.\\n\\n```mligo\\nlet () = \\n let ticket = Tezos.create_ticket \"Hi\" 10n in \\n let (ticketer, _, _, _) = Tezos.read_ticket ticket in \\n Test.log ticketer\\n\\n```\\n\\n"
merge_request: '3237'
title: "fix(interpreter): allow performing operations on tickets in tests"
type: fixed
\ No newline at end of file
......@@ -803,11 +803,11 @@
"tezos-ligo": {
"flake": false,
"locked": {
"lastModified": 1718272463,
"narHash": "sha256-RDF1F8oxu5TfKfvjl3ZzJKcnK8o9mOJo9FgpggUmZiE=",
"lastModified": 1721315580,
"narHash": "sha256-ZT6NYa640yiLBYOTGbXEzaTWR0dL4sH9bs0E0OKrLm8=",
"owner": "ligolang",
"repo": "tezos-ligo",
"rev": "556325b0c11fa2484d1e3e03f1dc91b384964ea9",
"rev": "68fd3b07a23914bab33fda5f7b70e329272088e5",
"type": "gitlab"
},
"original": {
......
......@@ -1369,36 +1369,14 @@ let rec compile_value ~raise ~options ~loc
"Expected sum type but got %a"
Ast_aggregated.PP.type_expression
ty)
| V_Record map when is_t_record ty ->
let map_ty =
Trace.trace_option
~raise
(Errors.generic_error
loc
(Format.asprintf
"Expected record type but got %a"
Ast_aggregated.PP.type_expression
ty))
@@ get_t_record_opt ty
in
let%map map_kv =
Lwt.map Ligo_prim.Record.of_list
@@ Lwt_list.map_s (fun (l, v) ->
let ty = Ligo_prim.Record.find map_ty.fields l in
let%map v = self v ty in
l, v)
@@ Ligo_prim.Record.to_list map
in
Trace.trace ~raise Main_errors.spilling_tracer
@@ Spilling.Layout.from_layout
(fun types ->
let types = List.map ~f:snd (Nonempty_list.to_list types) in
match types with
| [] -> Tezos_micheline.Micheline.Prim ((), "Unit", [], [])
| [ type_ ] -> type_
| types -> Tezos_micheline.Micheline.Prim ((), "Pair", types, []))
map_kv
map_ty.layout
| V_Record map when is_t_ticket ty ->
let content_ty =
Trace.trace_option ~raise (Errors.generic_error loc "Impossible: expected a ticket")
@@ get_t_ticket ty
in
let forged_ticket_ty = Ast_aggregated.t_forged_ticket ~loc content_ty in
compile_record ~raise ~options ~loc map forged_ticket_ty
| V_Record map when is_t_record ty -> compile_record ~raise ~options ~loc map ty
| V_List lst ->
let lst_ty =
Trace.trace_option
......@@ -1587,6 +1565,40 @@ let rec compile_value ~raise ~options ~loc
ty)
and compile_record ~raise ~options ~loc map ty =
let open Lwt.Let_syntax in
let open Ast_aggregated in
let map_ty =
Trace.trace_option
~raise
(Errors.generic_error
loc
(Format.asprintf
"Expected record type but got %a"
Ast_aggregated.PP.type_expression
ty))
@@ get_t_record_opt ty
in
let%map map_kv =
Lwt.map Ligo_prim.Record.of_list
@@ Lwt_list.map_s (fun (l, v) ->
let ty = Ligo_prim.Record.find map_ty.fields l in
let%map v = compile_value ~raise ~options ~loc v ty in
l, v)
@@ Ligo_prim.Record.to_list map
in
Trace.trace ~raise Main_errors.spilling_tracer
@@ Spilling.Layout.from_layout
(fun types ->
let types = List.map ~f:snd (Nonempty_list.to_list types) in
match types with
| [] -> Tezos_micheline.Micheline.Prim ((), "Unit", [], [])
| [ type_ ] -> type_
| types -> Tezos_micheline.Micheline.Prim ((), "Pair", types, []))
map_kv
map_ty.layout
let compile_type_to_mcode ~raise
: Ast_aggregated.type_expression -> Ligo_interpreter.Types.mcode
=
......
......@@ -117,6 +117,10 @@ let t_unforged_ticket ~loc ty : type_expression =
]
let t_forged_ticket ~loc ty : type_expression =
t_pair ~loc (t_address ~loc ()) (t_pair ~loc ty (t_nat ~loc ()))
let t_sum_ez
~loc
?(layout = default_layout)
......@@ -299,7 +303,8 @@ let is_t__type_ t = Option.is_some (get_t__type_ t)
, "contract"
, "map"
, "big_map"
, "typed_address" )]
, "typed_address"
, "ticket" )]
let is_t_mutez t = is_t_tez t
......
module Tezos = Tezos.Next
type transfer =
[@layout comb]
{ [@annot from] address_from : address;
......@@ -111,18 +113,18 @@ let getAllowance (param : getAllowance) (storage : storage) : operation list =
match Big_map.find_opt param.request storage.allowances with
| Some value -> value
| None -> 0n in
[Tezos.transaction (Main value) 0mutez param.callback]
[Tezos.Operation.transaction (Main value) 0mutez param.callback]
let getBalance (param : getBalance) (storage : storage) : operation list =
let value =
match Big_map.find_opt param.owner storage.tokens with
| Some value -> value
| None -> 0n in
[Tezos.transaction (Main value) 0mutez param.callback]
[Tezos.Operation.transaction (Main value) 0mutez param.callback]
let getTotalSupply (param : getTotalSupply) (storage : storage) : operation list =
let total = storage.total_supply in
[Tezos.transaction (Main total) 0mutez param.callback]
[Tezos.Operation.transaction (Main total) 0mutez param.callback]
[@entry]
let main (param : parameter) (storage : storage) : result =
......
module Test = Test.Next
type case =
{
case_name : string;
......@@ -23,5 +25,5 @@ let suite (name : string) (cases : case list) : suite =
}
let run_suite (suite : suite) =
let () = Test.println ("Running " ^ "<" ^ suite.suite_name ^ ">") in
let () = Test.IO.println ("Running " ^ "<" ^ suite.suite_name ^ ">") in
()
#import "./contract_under_test/contract_create.mligo" "C"
let assert = Assert.assert
module Test = Test.Next
let test =
let orig = Test.originate (contract_of C) None 0tez in
let contr = Test.to_contract orig.addr in
match Test.transfer_to_contract contr (Main Two) 1mutez with
let orig = Test.Originate.contract (contract_of C) None 0tez in
let contr = Test.Typed_address.to_contract orig.taddr in
match Test.Contract.transfer contr (Main Two) 1mutez with
(* TODO this is a bug :( *)
| Fail (Balance_too_low {contract_too_low = _ ; contract_balance ; spend_request}) ->
let () = assert (contract_balance = 1mutez) in
......
module Test = Test.Next
let assert = Assert.assert
(* Some basic types and functions *)
type some_r = [@layout comb] { one : int ; two : nat ; three : string ; four : bytes ; five : unit }
type some_v = [@layout comb] | Foo of int | Bar of string | Bare of string | Baz of nat
let f = fun (x:some_r) -> x.one
......@@ -8,23 +12,23 @@ type some_v_2 = [@layout tree] | Foo2 of int | Bar2 of string | Bare2 of string
let f_2 = fun (x:some_r_2) -> x.one2
let test1 =
let d_one = Test.eval (1 + 3 + 2) in
let ret = Test.run (fun (x : (int * nat * string * bytes * unit)) -> f ({ one = x.0 ; two = x.1 ; three = x.2 ; four = x.3 ; five = x.4 } : some_r))
let d_one = Test.Michelson.eval (1 + 3 + 2) in
let ret = Test.Michelson.run (fun (x : (int * nat * string * bytes * unit)) -> f ({ one = x.0 ; two = x.1 ; three = x.2 ; four = x.3 ; five = x.4 } : some_r))
(1 + 3 + 2, 1n + 2n, "a" ^ "b", 0xFF00, ()) in
assert (Test.michelson_equal d_one ret)
assert (Test.Compare.eq d_one ret)
let test2 =
let x1 = Test.eval (1,2) in
let x2 = Test.run (fun (x : int * int) -> x) (1, 2) in
let eq = Test.michelson_equal x1 x2 in
let x1 = Test.Michelson.eval (1,2) in
let x2 = Test.Michelson.run (fun (x : int * int) -> x) (1, 2) in
let eq = Test.Compare.eq x1 x2 in
assert eq
let test3 =
let x1 = Test.eval (Baz 1n : some_v) in
let x2 = Test.eval (Baz2 1n : some_v_2) in
assert (not (Test.michelson_equal x1 x2))
let x1 = Test.Michelson.eval (Baz 1n : some_v) in
let x2 = Test.Michelson.eval (Baz2 1n : some_v_2) in
assert (not (Test.Compare.eq x1 x2))
let test4 =
let x1 = Test.eval ({ one = 1 ; two = 2n ; three = "a" ; four = 0xFF00 ; five = () } : some_r) in
let x2 = Test.eval ({ one2 = 1 ; two2 = 2n ; three2 = "a" ; four2 = 0xFF00 ; five2 = () } : some_r_2) in
assert (not (Test.michelson_equal x1 x2))
let x1 = Test.Michelson.eval ({ one = 1 ; two = 2n ; three = "a" ; four = 0xFF00 ; five = () } : some_r) in
let x2 = Test.Michelson.eval ({ one2 = 1 ; two2 = 2n ; three2 = "a" ; four2 = 0xFF00 ; five2 = () } : some_r_2) in
assert (not (Test.Compare.eq x1 x2))
module Test = Test.Next
let assert = Assert.assert
let test1 =
type r_comb = [@layout comb] { one : int ; two : nat ; three : string ; four : bytes ; five : unit } in
let d_one = Test.compile_value (1 + 3 + 5) in
let d_one = Test.Michelson.eval (1 + 3 + 5) in
let v = {one = 1 + 3 + 5 ; two = 1n +2n ; three = "a"^"b" ; four = 0xFF00 ; five = ()} in
let ret = Test.run (fun (x:r_comb) -> x.one ) v in
assert (Test.michelson_equal d_one ret)
let ret = Test.Michelson.run (fun (x:r_comb) -> x.one ) v in
assert (Test.Compare.eq d_one ret)
let test2 =
let x1 = Test.compile_value (1,2) in
let x2 = Test.run (fun () -> (1,2)) () in
let eq = Test.michelson_equal x1 x2 in
let x1 = Test.Michelson.eval (1,2) in
let x2 = Test.Michelson.run (fun () -> (1,2)) () in
let eq = Test.Compare.eq x1 x2 in
assert eq
let test3 =
let x1 =
type r_comb = [@layout comb] { one : int ; two : nat ; three : string ; four : bytes ; five : unit } in
Test.run (fun () -> ({one = 1 ; two = 2n ; three = "a" ; four = 0xFF00 ; five = ()}:r_comb)) ()
Test.Michelson.run (fun () -> ({one = 1 ; two = 2n ; three = "a" ; four = 0xFF00 ; five = ()}:r_comb)) ()
in
let x2 =
type r_tree = [@layout tree] { one : int ; two : nat ; three : string ; four : bytes ; five : unit } in
Test.run (fun () -> ({one = 1 ; two = 2n ; three = "a" ; four = 0xFF00 ; five = ()}:r_tree)) ()
Test.Michelson.run (fun () -> ({one = 1 ; two = 2n ; three = "a" ; four = 0xFF00 ; five = ()}:r_tree)) ()
in
assert (not (Test.michelson_equal x1 x2))
assert (not (Test.Compare.eq x1 x2))
let test4 =
let x1 =
type v_comb = [@layout comb] | Foo of int | Bar of string | Bare of string | Baz of nat in
Test.run (fun () -> (Baz 1n: v_comb)) ()
Test.Michelson.run (fun () -> (Baz 1n: v_comb)) ()
in
let x2 =
type v_tree = [@layout tree] | Foo of int | Bar of string | Bare of string | Baz of nat in
Test.run (fun () -> (Baz 1n: v_tree)) ()
Test.Michelson.run (fun () -> (Baz 1n: v_tree)) ()
in
assert (not (Test.michelson_equal x1 x2))
assert (not (Test.Compare.eq x1 x2))
......@@ -12,14 +12,14 @@ let main (action : parameter) (store : storage) : return =
in
let c : nat contract option = Tezos.get_contract_opt a in
let ops = match c with
Some (c) -> [ Tezos.transaction 1n 10tez c ]
Some (c) -> [ Tezos.Next.Operation.transaction 1n 10tez c ]
| None -> (failwith 2 : operation list)
in
(ops, (None: storage))
| Two ->
let x : operation * address = Tezos.create_contract
(fun (_p : nat) (_s : string) -> (failwith 111: operation list * string))
(None: key_hash option)
(None: key_hash option)
1tz
"un"
in
......
let assert = Assert.assert
type storage = (bytes ticket) option
type unforged_storage = (bytes unforged_ticket) option
......@@ -5,7 +7,7 @@ let main (() : unit) (s : storage) : operation list * storage =
[] , (
match s with
| Some ticket ->
let (_ , t) = Tezos.read_ticket ticket in
let (_ , t) = Tezos.Next.Ticket.read ticket in
Some t
| None -> None
)
......@@ -19,8 +21,8 @@ let test_originate_contract =
match unforged_storage with
| Some { ticketer=_ ; value ; amount } ->
let () = Test.log ("unforged_ticket", unforged_storage) in
let () = Test.Next.IO.log ("unforged_ticket", unforged_storage) in
let () = assert (value = ticket_info.0) in
let () = assert (amount = ticket_info.1) in
()
| None -> failwith "impossible"
\ No newline at end of file
| None -> failwith "impossible"
import Test = Test.Next;
const assert = Test.Assert.assert
const getChar = (s: string, idx: nat): string => String.sub(idx, 1 as nat, s)
const isPalindrome = (s: string): bool => {
......@@ -20,15 +23,15 @@ const isPalindrome_ = (s: string): bool => {
const testPalindrome = (() => {
const abba = "abba";
Test.assert(isPalindrome(abba));
Test.assert(isPalindrome_(abba));
assert(isPalindrome(abba));
assert(isPalindrome_(abba));
const ababa = "ababa";
Test.assert(isPalindrome(ababa));
Test.assert(isPalindrome_(ababa));
assert(isPalindrome(ababa));
assert(isPalindrome_(ababa));
const abcd = "abcd";
Test.assert(!isPalindrome(abcd));
Test.assert(!isPalindrome_(abcd));
assert(!isPalindrome(abcd));
assert(!isPalindrome_(abcd));
const abcde = "abcde";
Test.assert(!isPalindrome(abcde));
Test.assert(!isPalindrome_(abcde));
})();
\ No newline at end of file
assert(!isPalindrome(abcde));
assert(!isPalindrome_(abcde));
})();
module Test = Test.Next
module C = struct
let michelson_add : int * int -> int =
[%Michelson ({| { UNPAIR ; ADD } |} : int * int -> int) ]
......@@ -8,6 +10,6 @@ module C = struct
end
let test =
let orig = Test.originate (contract_of C) 1 0tez in
let _ = Test.transfer_exn orig.addr (Main 41) 0tez in
Test.log (Test.get_storage orig.addr)
let orig = Test.Originate.contract (contract_of C) 1 0tez in
let _ = Test.Typed_address.transfer_exn orig.taddr (Main 41) 0tez in
Test.IO.log (Test.Typed_address.get_storage orig.taddr)
let assert = Assert.assert
module C = struct
type storage = int list
type parameter = bool
......@@ -14,14 +16,14 @@ let test =
if p = 0 then acc else aux (p::acc) (p-1)
in aux ([]:int list) 2000
in
let orig = Test.originate (contract_of C) big_list 0tez in
let orig = Test.Next.Originate.contract (contract_of C) big_list 0tez in
let _caching =
(* some caching is happening on the first transaction *)
Test.transfer orig.addr (Main true) 0tez
Test.Next.Typed_address.transfer orig.taddr (Main true) 0tez
in
let tx1 = Test.transfer orig.addr (Main false) 0tez in
let tx2 = Test.transfer orig.addr (Main true) 0tez in
let tx3 = Test.transfer orig.addr (Main true) 0tez in
let tx1 = Test.Next.Typed_address.transfer orig.taddr (Main false) 0tez in
let tx2 = Test.Next.Typed_address.transfer orig.taddr (Main true) 0tez in
let tx3 = Test.Next.Typed_address.transfer orig.taddr (Main true) 0tez in
match (tx1 , tx2, tx3) with
| Success cons1 , Success cons2, Success cons3 ->
let () = assert ((cons1 < cons2) && (cons2 = cons3)) in
......
module Test = Test.Next
module C = struct
type parameter = Foo of int | Bar of nat
......@@ -8,13 +10,13 @@ module C = struct
end
let test =
let orig = Test.originate (contract_of C) 0 0tez in
let ta = orig.addr in
let c = Test.to_contract ta in
let orig = Test.Originate.contract (contract_of C) 0 0tez in
let ta = orig.taddr in
let c = Test.Typed_address.to_contract ta in
let a = Tezos.address c in
let () = assert_some (Tezos.get_entrypoint_opt "%foo" a : (int contract) option) in
let () = Assert.some (Tezos.get_entrypoint_opt "%foo" a : (int contract) option) in
let _ = (Tezos.get_entrypoint "%foo" a : (int contract)) in
let () = assert_some (Tezos.get_contract_opt a : ((C parameter_of) contract) option) in
let () = Assert.some (Tezos.get_contract_opt a : ((C parameter_of) contract) option) in
let _ = (Tezos.get_contract a : ((C parameter_of) contract)) in
let _ = (Tezos.get_contract_with_error a "foo" : ((C parameter_of) contract)) in
()
#import "main.mligo" "Main"
module Test = Test.Next
let test1 =
let _ = Test.originate (contract_of Main) "a" 1tez in
()
\ No newline at end of file
let _ = Test.Originate.contract (contract_of Main) "a" 1tez in
()
module Test = Test.Next
let assert = Test.Assert.assert
let test_lambda_call =
let a = 3 in
let foo = fun (i : int) -> i * i in
......@@ -374,19 +378,19 @@ let test_bytes_sub =
assert (Bytes.sub 0n 1n (Bytes.pack 5n) = 0x05)
let test_with_error =
assert_with_error true "foo"
Assert.Error.assert true "foo"
let test_some =
assert_some (Some 1 : int option)
Assert.some (Some 1 : int option)
let test_some_with_error =
assert_some_with_error (Some 2 : int option) "bar"
Assert.Error.some (Some 2 : int option) "bar"
let test_none =
assert_none (None : int option)
Assert.none (None : int option)
let test_none_with_error =
assert_none_with_error (None : int option) "bar"
Assert.Error.none (None : int option) "bar"
let test_unopt =
assert (Option.value_with_error "option is None" (Some 1 : int option) = 1)
......@@ -398,7 +402,7 @@ let test_sha256 =
let hash5n = (0xf6c5c0ad2216920e105be5e940c4a71ead0741f9dbdb32bfab9570df57cc983a : bytes) in
let hashempty = (0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 : bytes) in
let () = assert (Crypto.sha256 (Bytes.pack 5n) = hash5n) in
let () = assert (Test.eval (Crypto.sha256 (Bytes.pack 5n)) = Test.run (fun (n : nat) -> Crypto.sha256 (Bytes.pack n)) 5n) in
let () = assert (Test.Michelson.eval (Crypto.sha256 (Bytes.pack 5n)) = Test.Michelson.run (fun (n : nat) -> Crypto.sha256 (Bytes.pack n)) 5n) in
assert (Crypto.sha256 (Bytes.sub 0n 0n (Bytes.pack 5n)) = hashempty)
let test_sha512 =
......@@ -407,34 +411,34 @@ let test_sha512 =
let hashempty =
(0xcf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e : bytes) in
let () = assert (Crypto.sha512 (Bytes.pack 5n) = hash5n) in
let () = assert (Test.eval (Crypto.sha512 (Bytes.pack 5n)) = Test.run (fun (n : nat) -> Crypto.sha512 (Bytes.pack n)) 5n) in
let () = assert (Test.Michelson.eval (Crypto.sha512 (Bytes.pack 5n)) = Test.Michelson.run (fun (n : nat) -> Crypto.sha512 (Bytes.pack n)) 5n) in
assert (Crypto.sha512 (Bytes.sub 0n 0n (Bytes.pack 5n)) = hashempty)
let test_blake2b =
let hash5n = (0x2af6f7eb61511de4fa3a667a63e2f26f9c506042b335e62fed916335d04a08ed : bytes) in
let hashempty = (0x0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8 : bytes) in
let () = assert (Crypto.blake2b (Bytes.pack 5n) = hash5n) in
let () = assert (Test.eval (Crypto.blake2b (Bytes.pack 5n)) = Test.run (fun (n : nat) -> Crypto.blake2b (Bytes.pack n)) 5n) in
let () = assert (Test.Michelson.eval (Crypto.blake2b (Bytes.pack 5n)) = Test.Michelson.run (fun (n : nat) -> Crypto.blake2b (Bytes.pack n)) 5n) in
assert (Crypto.blake2b (Bytes.sub 0n 0n (Bytes.pack 5n)) = hashempty)
let test_keccak =
let hash5n = (0xb40da68da4779bf68d31e6ab2eb21c26d950cc23e13efb4da0ec424f138000c3 : bytes) in
let hashempty = (0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 : bytes) in
let () = assert (Crypto.keccak (Bytes.pack 5n) = hash5n) in
let () = assert (Test.eval (Crypto.keccak (Bytes.pack 5n)) = Test.run (fun (n : nat) -> Crypto.keccak (Bytes.pack n)) 5n) in
let () = assert (Test.Michelson.eval (Crypto.keccak (Bytes.pack 5n)) = Test.Michelson.run (fun (n : nat) -> Crypto.keccak (Bytes.pack n)) 5n) in
assert (Crypto.keccak (Bytes.sub 0n 0n (Bytes.pack 5n)) = hashempty)
let test_sha3 =
let hash5n = (0xfe2ecff30c0281f99ad639b9cfa50970ee98b382fa1688cef0bd33c7f5b0be16 : bytes) in
let hashempty = (0xa7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a : bytes) in
let () = assert (Crypto.sha3 (Bytes.pack 5n) = hash5n) in
let () = assert (Test.eval (Crypto.sha3 (Bytes.pack 5n)) = Test.run (fun (n : nat) -> Crypto.sha3 (Bytes.pack n)) 5n) in
let () = assert (Test.Michelson.eval (Crypto.sha3 (Bytes.pack 5n)) = Test.Michelson.run (fun (n : nat) -> Crypto.sha3 (Bytes.pack n)) 5n) in
assert (Crypto.sha3 (Bytes.sub 0n 0n (Bytes.pack 5n)) = hashempty)
let test_key_hash =
let key = ("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav" : key) in
let key_hash = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : key_hash) in
let () = assert (Test.eval (Crypto.hash_key key) = Test.run (fun (k : key) -> Crypto.hash_key k) key) in
let () = assert (Test.Michelson.eval (Crypto.hash_key key) = Test.Michelson.run (fun (k : key) -> Crypto.hash_key k) key) in
assert (Crypto.hash_key key = key_hash)
let test_check =
......@@ -448,16 +452,16 @@ let test_check =
let test_int_bls =
let alpha = (0xe406000000000000000000000000000000000000000000000000000000000000 : bls12_381_fr) in
let alpha_int = int alpha in
let mich_int = Test.run (fun (_ : unit) -> int (0xe406000000000000000000000000000000000000000000000000000000000000 : bls12_381_fr)) () in
assert (Test.eval alpha_int = mich_int)
let mich_int = Test.Michelson.run (fun (_ : unit) -> int (0xe406000000000000000000000000000000000000000000000000000000000000 : bls12_381_fr)) () in
assert (Test.Michelson.eval alpha_int = mich_int)
let test_not =
let f ((x, y) : nat * int) : int = x * not y in
assert (Test.eval (f (313n , 2938818607801353443)) = Test.run f (313n , 2938818607801353443))
assert (Test.Michelson.eval (f (313n , 2938818607801353443)) = Test.Michelson.run f (313n , 2938818607801353443))
let test_chain_id =
let chain_id = Test.eval ("NetXH12Aer3be93" : chain_id) in
assert (chain_id = Test.eval (Tezos.get_chain_id ()))
let chain_id = Test.Michelson.eval ("NetXH12Aer3be93" : chain_id) in
assert (chain_id = Test.Michelson.eval (Tezos.get_chain_id ()))
let test_concats =
let ss = ["aa"; "bb"; ""; "cc"] in
......@@ -466,8 +470,8 @@ let test_concats =
let () = assert (Bytes.concats bs = (0x00010203 : bytes)) in
let () = assert (String.concats [] = "") in
let () = assert (Bytes.concats [] = Bytes.sub 0n 0n (0x00 : bytes)) in
let () = assert (Test.run (fun () -> String.concats ss) () = Test.eval (String.concats ss)) in
let () = assert (Test.run (fun () -> Bytes.concats bs) () = Test.eval (Bytes.concats bs)) in
let () = assert (Test.Michelson.run (fun () -> String.concats ss) () = Test.Michelson.eval (String.concats ss)) in
let () = assert (Test.Michelson.run (fun () -> Bytes.concats bs) () = Test.Michelson.eval (Bytes.concats bs)) in
()
let test_bytes_nat_int_conversion =
......
module Test = Test.Next
type parameter = One | Two
type some_record = { a : int ; b : nat ; c : string }
......@@ -6,6 +8,6 @@ let () =
let v1 = { a= 1 ; b = 2n ; c = "aaa" } in
let v2 = One in
begin
Test.log v1 ;
Test.log v2
Test.IO.log v1 ;
Test.IO.log v2
end
let assert = Assert.assert
type storage = {
tokenPool : nat ;
cashPool : nat ;
......@@ -9,7 +11,7 @@ type storage = {
lqtAddress : address ;
}
let initial_storage =
let initial_storage =
{ tokenPool = 103n ;
cashPool = 204n ;
lqtTotal = 10n ;
......