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
Select Git revision
  • 10-visual-overhaul-of-the-ligo-website
  • 1045-compiler-version-select-in-webide
  • 1053-ability-to-compile-a-single-function
  • 1053-renaming-configure-options
  • 113-status-error-does-not-preserve-the-failwith-string
  • 1185-Dark-Mode
  • 1228-add-a-way-to-get-the-michelson-representation-of-a-type
  • 1238-pascalligo-compiler-types-optimization-could-break-contracts
  • 127-unsupported-bytes_unpack-in-pascaligo
  • 1298-test-netlify-publish
  • 132-errors-location-on-expression-given-as-command-line-argument
  • 1361-get-current-voting_period_index-inside-the-smartcontract-and-also-be-able-to-set-it-on-the
  • 149-combination-of-multi-argument-function-and-list-map-lambda-gives-bad-contract-type-compilation
  • 1499-add-open-directive-for-modules
  • 1632-the-handling-of-escaped-identifiers-prefixed-is-a-hack
  • 1692-wildcard-is-parsed-as-a-variable-in-jsligo
  • 1758-confidential-issue
  • 1791-contract-abstraction-dynamic-entrypoints
  • 2149-auto-generation-of-tzip16-source-metadata
  • 23-higher-order-functions-with-more-than-one-argument-give-weird-errors
  • 3-adding-odoc-doc-to-the-website
  • 7-makefile
  • 73-error-when-dry-running-a-contract-having-a-storage-which-contains-a-lambda
  • 8-reporting-of-error-messages
  • 93-compiler-allows-parameter-named-source-but-translates-it-to-source
  • 972-add-position-of-cursor-into-gutter
  • 99-ligo-dies-instead
  • @anchpop/add-backends-folder
  • @anchpop/add-devcontainer
  • @anchpop/add-dune-project
  • @anchpop/let-type-vars
  • @anchpop/split-off-types-package
  • @anchpop/use-dune-for-vendoring
  • CI-cache
  • LIGO-92-buttons
  • LIGO-93-profiles
  • LIGO-95-layout
  • LIGO-96-partners-redesign
  • Ligo-Snippets-Editor
  • Sorokin-Anton/#1889-add-batcher-benchmarks
  • Sorokin-Anton/#1919-range-formatting-and-comments
  • Sorokin-Anton/#2094-markdown-docs
  • Sorokin-Anton/#2094-mdx-docs-new-stdlib
  • Sorokin-Anton/fold-jsligo
  • Sorokin-Anton/tmp-call-processing-on-document-link
  • Sorokin-Anton/trying-to-expose-use-orig-var
  • WebIDE-Changes
  • add-ide
  • add-run-script
  • add/bugs_field_in_manifest
  • add/primitives_in_init_env
  • add_entrypoint_annotation
  • add_entrypoint_annotation-upd
  • add_include_directive_bis
  • add_open_directive
  • add_pkgbuild
  • aggressive-inlining
  • ajob/dependent-types
  • ajob410/bidir-annot-improvements
  • ajob410/bidir-optimizations
  • ajob410/bidir-v2-union-find
  • ajob410/constant-error-message-fix
  • ajob410/contract-checking
  • ajob410/contracts-cameligo-parser
  • ajob410/frontend-pruning
  • ajob410/please-rebase-on-me
  • ajob410@add-devtools-to-nix-shell
  • ajob410@ci-ocamlformat-check
  • ajob410@deprecate-main
  • ajob410@merge-ligo-syntax-libs
  • ajob410@mv-ligo-interpreter
  • ajob410@nix-fix-darwin
  • ajob410@nix-webide-docker
  • ajob410@paris-a-upgrade
  • ajob410@test-md-fixes
  • ajob410@typer-error-recovery
  • ajob41@chore/prometheus-gateway-url
  • alan@lltz_codegen/stability_and_optimizations
  • alternate-api-deployment
  • api-docs-syntax-headers
  • assignements-with-carthage
  • ast/main
  • ast/match_tuple_record_variable
  • ast/ordering-ast_making_types
  • ast/t_existentials
  • ast/tuple_destruct
  • automatic_changelog
  • back_interpret_test_new_feature
  • backend-pre-setup
  • ballec
  • balsoft/opam
  • benchmarks
  • bfamchon@documentation-categories-rework
  • bugfix_0.16.1
  • build-test-fix
  • build/alpha
  • build/compilation
  • build/module
  • cameligo2
  • cancel-rev
  • 0.0.0
  • 0.0.1
  • 0.0.20230804
  • 0.1.0
  • 0.1.20230804
  • 0.1.2023080401
  • 0.10.0
  • 0.11.0
  • 0.12.0
  • 0.13.0
  • 0.14.0
  • 0.15.0
  • 0.16.0
  • 0.16.1
  • 0.17.0
  • 0.18.0
  • 0.19.0
  • 0.2.0
  • 0.2.1
  • 0.20.0
  • 0.21.0
  • 0.22.0
  • 0.23.0
  • 0.24.0
  • 0.25.0
  • 0.26.0
  • 0.27.0
  • 0.28.0
  • 0.29.0
  • 0.3.0
  • 0.30.0
  • 0.31.0
  • 0.32.0
  • 0.33.0
  • 0.34.0
  • 0.35.0
  • 0.36.0
  • 0.37.0
  • 0.38.0
  • 0.38.1
  • 0.39.0
  • 0.4.0
  • 0.40.0
  • 0.41.0
  • 0.42.0
  • 0.42.1
  • 0.43.0
  • 0.44.0
  • 0.45.0
  • 0.46.0
  • 0.46.1
  • 0.47.0
  • 0.48.0
  • 0.48.1
  • 0.49.0
  • 0.5.0
  • 0.50.0
  • 0.51.0
  • 0.52.0
  • 0.53.0
  • 0.54.0
  • 0.54.1
  • 0.55.0
  • 0.56.0
  • 0.57.0
  • 0.58.0
  • 0.59.0
  • 0.6.0
  • 0.60.0
  • 0.61.0
  • 0.62.0
  • 0.63.0
  • 0.63.2
  • 0.64.2
  • 0.64.3
  • 0.65.0
  • 0.66.0
  • 0.67.0
  • 0.67.1
  • 0.68.0
  • 0.69.0
  • 0.7.0
  • 0.7.1
  • 0.70.0
  • 0.70.1
  • 0.71.0
  • 0.71.1
  • 0.72.0
  • 0.73.0
  • 0.8.0
  • 0.9.0
  • 0.9.0-liquidity-baking
  • 1.0.0
  • 1.1.0
  • 1.10.0
  • 1.2.0
  • 1.3.0
  • 1.4.0
  • 1.5.0
  • 1.6.0
200 results

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
Select Git revision
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 @@ ...@@ -803,11 +803,11 @@
"tezos-ligo": { "tezos-ligo": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1718272463, "lastModified": 1721315580,
"narHash": "sha256-RDF1F8oxu5TfKfvjl3ZzJKcnK8o9mOJo9FgpggUmZiE=", "narHash": "sha256-ZT6NYa640yiLBYOTGbXEzaTWR0dL4sH9bs0E0OKrLm8=",
"owner": "ligolang", "owner": "ligolang",
"repo": "tezos-ligo", "repo": "tezos-ligo",
"rev": "556325b0c11fa2484d1e3e03f1dc91b384964ea9", "rev": "68fd3b07a23914bab33fda5f7b70e329272088e5",
"type": "gitlab" "type": "gitlab"
}, },
"original": { "original": {
......
...@@ -1369,36 +1369,14 @@ let rec compile_value ~raise ~options ~loc ...@@ -1369,36 +1369,14 @@ let rec compile_value ~raise ~options ~loc
"Expected sum type but got %a" "Expected sum type but got %a"
Ast_aggregated.PP.type_expression Ast_aggregated.PP.type_expression
ty) ty)
| V_Record map when is_t_record ty -> | V_Record map when is_t_ticket ty ->
let map_ty = let content_ty =
Trace.trace_option Trace.trace_option ~raise (Errors.generic_error loc "Impossible: expected a ticket")
~raise @@ get_t_ticket ty
(Errors.generic_error in
loc let forged_ticket_ty = Ast_aggregated.t_forged_ticket ~loc content_ty in
(Format.asprintf compile_record ~raise ~options ~loc map forged_ticket_ty
"Expected record type but got %a" | V_Record map when is_t_record ty -> compile_record ~raise ~options ~loc map ty
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_List lst -> | V_List lst ->
let lst_ty = let lst_ty =
Trace.trace_option Trace.trace_option
...@@ -1587,6 +1565,40 @@ let rec compile_value ~raise ~options ~loc ...@@ -1587,6 +1565,40 @@ let rec compile_value ~raise ~options ~loc
ty) 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 let compile_type_to_mcode ~raise
: Ast_aggregated.type_expression -> Ligo_interpreter.Types.mcode : Ast_aggregated.type_expression -> Ligo_interpreter.Types.mcode
= =
......
...@@ -117,6 +117,10 @@ let t_unforged_ticket ~loc ty : type_expression = ...@@ -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 let t_sum_ez
~loc ~loc
?(layout = default_layout) ?(layout = default_layout)
...@@ -299,7 +303,8 @@ let is_t__type_ t = Option.is_some (get_t__type_ t) ...@@ -299,7 +303,8 @@ let is_t__type_ t = Option.is_some (get_t__type_ t)
, "contract" , "contract"
, "map" , "map"
, "big_map" , "big_map"
, "typed_address" )] , "typed_address"
, "ticket" )]
let is_t_mutez t = is_t_tez t let is_t_mutez t = is_t_tez t
......
module Tezos = Tezos.Next
type transfer = type transfer =
[@layout comb] [@layout comb]
{ [@annot from] address_from : address; { [@annot from] address_from : address;
...@@ -111,18 +113,18 @@ let getAllowance (param : getAllowance) (storage : storage) : operation list = ...@@ -111,18 +113,18 @@ let getAllowance (param : getAllowance) (storage : storage) : operation list =
match Big_map.find_opt param.request storage.allowances with match Big_map.find_opt param.request storage.allowances with
| Some value -> value | Some value -> value
| None -> 0n in | 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 getBalance (param : getBalance) (storage : storage) : operation list =
let value = let value =
match Big_map.find_opt param.owner storage.tokens with match Big_map.find_opt param.owner storage.tokens with
| Some value -> value | Some value -> value
| None -> 0n in | 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 getTotalSupply (param : getTotalSupply) (storage : storage) : operation list =
let total = storage.total_supply in let total = storage.total_supply in
[Tezos.transaction (Main total) 0mutez param.callback] [Tezos.Operation.transaction (Main total) 0mutez param.callback]
[@entry] [@entry]
let main (param : parameter) (storage : storage) : result = let main (param : parameter) (storage : storage) : result =
......
module Test = Test.Next
type case = type case =
{ {
case_name : string; case_name : string;
...@@ -23,5 +25,5 @@ let suite (name : string) (cases : case list) : suite = ...@@ -23,5 +25,5 @@ let suite (name : string) (cases : case list) : suite =
} }
let run_suite (suite : 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" #import "./contract_under_test/contract_create.mligo" "C"
let assert = Assert.assert
module Test = Test.Next
let test = let test =
let orig = Test.originate (contract_of C) None 0tez in let orig = Test.Originate.contract (contract_of C) None 0tez in
let contr = Test.to_contract orig.addr in let contr = Test.Typed_address.to_contract orig.taddr in
match Test.transfer_to_contract contr (Main Two) 1mutez with match Test.Contract.transfer contr (Main Two) 1mutez with
(* TODO this is a bug :( *) (* TODO this is a bug :( *)
| Fail (Balance_too_low {contract_too_low = _ ; contract_balance ; spend_request}) -> | Fail (Balance_too_low {contract_too_low = _ ; contract_balance ; spend_request}) ->
let () = assert (contract_balance = 1mutez) in let () = assert (contract_balance = 1mutez) in
......
module Test = Test.Next
let assert = Assert.assert
(* Some basic types and functions *) (* Some basic types and functions *)
type some_r = [@layout comb] { one : int ; two : nat ; three : string ; four : bytes ; five : unit } 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 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 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 ...@@ -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 f_2 = fun (x:some_r_2) -> x.one2
let test1 = let test1 =
let d_one = Test.eval (1 + 3 + 2) in let d_one = Test.Michelson.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 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 (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 test2 =
let x1 = Test.eval (1,2) in let x1 = Test.Michelson.eval (1,2) in
let x2 = Test.run (fun (x : int * int) -> x) (1, 2) in let x2 = Test.Michelson.run (fun (x : int * int) -> x) (1, 2) in
let eq = Test.michelson_equal x1 x2 in let eq = Test.Compare.eq x1 x2 in
assert eq assert eq
let test3 = let test3 =
let x1 = Test.eval (Baz 1n : some_v) in let x1 = Test.Michelson.eval (Baz 1n : some_v) in
let x2 = Test.eval (Baz2 1n : some_v_2) in let x2 = Test.Michelson.eval (Baz2 1n : some_v_2) in
assert (not (Test.michelson_equal x1 x2)) assert (not (Test.Compare.eq x1 x2))
let test4 = let test4 =
let x1 = Test.eval ({ one = 1 ; two = 2n ; three = "a" ; four = 0xFF00 ; five = () } : some_r) in let x1 = Test.Michelson.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 let x2 = Test.Michelson.eval ({ one2 = 1 ; two2 = 2n ; three2 = "a" ; four2 = 0xFF00 ; five2 = () } : some_r_2) in
assert (not (Test.michelson_equal x1 x2)) assert (not (Test.Compare.eq x1 x2))
module Test = Test.Next
let assert = Assert.assert
let test1 = let test1 =
type r_comb = [@layout comb] { one : int ; two : nat ; three : string ; four : bytes ; five : unit } in 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 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 let ret = Test.Michelson.run (fun (x:r_comb) -> x.one ) v in
assert (Test.michelson_equal d_one ret) assert (Test.Compare.eq d_one ret)
let test2 = let test2 =
let x1 = Test.compile_value (1,2) in let x1 = Test.Michelson.eval (1,2) in
let x2 = Test.run (fun () -> (1,2)) () in let x2 = Test.Michelson.run (fun () -> (1,2)) () in
let eq = Test.michelson_equal x1 x2 in let eq = Test.Compare.eq x1 x2 in
assert eq assert eq
let test3 = let test3 =
let x1 = let x1 =
type r_comb = [@layout comb] { one : int ; two : nat ; three : string ; four : bytes ; five : unit } in 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 in
let x2 = let x2 =
type r_tree = [@layout tree] { one : int ; two : nat ; three : string ; four : bytes ; five : unit } in 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 in
assert (not (Test.michelson_equal x1 x2)) assert (not (Test.Compare.eq x1 x2))
let test4 = let test4 =
let x1 = let x1 =
type v_comb = [@layout comb] | Foo of int | Bar of string | Bare of string | Baz of nat in 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 in
let x2 = let x2 =
type v_tree = [@layout tree] | Foo of int | Bar of string | Bare of string | Baz of nat in 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 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 = ...@@ -12,14 +12,14 @@ let main (action : parameter) (store : storage) : return =
in in
let c : nat contract option = Tezos.get_contract_opt a in let c : nat contract option = Tezos.get_contract_opt a in
let ops = match c with 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) | None -> (failwith 2 : operation list)
in in
(ops, (None: storage)) (ops, (None: storage))
| Two -> | Two ->
let x : operation * address = Tezos.create_contract let x : operation * address = Tezos.create_contract
(fun (_p : nat) (_s : string) -> (failwith 111: operation list * string)) (fun (_p : nat) (_s : string) -> (failwith 111: operation list * string))
(None: key_hash option) (None: key_hash option)
1tz 1tz
"un" "un"
in in
......
let assert = Assert.assert
type storage = (bytes ticket) option type storage = (bytes ticket) option
type unforged_storage = (bytes unforged_ticket) option type unforged_storage = (bytes unforged_ticket) option
...@@ -5,7 +7,7 @@ let main (() : unit) (s : storage) : operation list * storage = ...@@ -5,7 +7,7 @@ let main (() : unit) (s : storage) : operation list * storage =
[] , ( [] , (
match s with match s with
| Some ticket -> | Some ticket ->
let (_ , t) = Tezos.read_ticket ticket in let (_ , t) = Tezos.Next.Ticket.read ticket in
Some t Some t
| None -> None | None -> None
) )
...@@ -19,8 +21,8 @@ let test_originate_contract = ...@@ -19,8 +21,8 @@ let test_originate_contract =
match unforged_storage with match unforged_storage with
| Some { ticketer=_ ; value ; amount } -> | 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 (value = ticket_info.0) in
let () = assert (amount = ticket_info.1) in let () = assert (amount = ticket_info.1) in
() ()
| None -> failwith "impossible" | None -> failwith "impossible"
\ No newline at end of file
import Test = Test.Next;
const assert = Test.Assert.assert
const getChar = (s: string, idx: nat): string => String.sub(idx, 1 as nat, s) const getChar = (s: string, idx: nat): string => String.sub(idx, 1 as nat, s)
const isPalindrome = (s: string): bool => { const isPalindrome = (s: string): bool => {
...@@ -20,15 +23,15 @@ const isPalindrome_ = (s: string): bool => { ...@@ -20,15 +23,15 @@ const isPalindrome_ = (s: string): bool => {
const testPalindrome = (() => { const testPalindrome = (() => {
const abba = "abba"; const abba = "abba";
Test.assert(isPalindrome(abba)); assert(isPalindrome(abba));
Test.assert(isPalindrome_(abba)); assert(isPalindrome_(abba));
const ababa = "ababa"; const ababa = "ababa";
Test.assert(isPalindrome(ababa)); assert(isPalindrome(ababa));
Test.assert(isPalindrome_(ababa)); assert(isPalindrome_(ababa));
const abcd = "abcd"; const abcd = "abcd";
Test.assert(!isPalindrome(abcd)); assert(!isPalindrome(abcd));
Test.assert(!isPalindrome_(abcd)); assert(!isPalindrome_(abcd));
const abcde = "abcde"; const abcde = "abcde";
Test.assert(!isPalindrome(abcde)); assert(!isPalindrome(abcde));
Test.assert(!isPalindrome_(abcde)); assert(!isPalindrome_(abcde));
})(); })();
\ No newline at end of file
module Test = Test.Next
module C = struct module C = struct
let michelson_add : int * int -> int = let michelson_add : int * int -> int =
[%Michelson ({| { UNPAIR ; ADD } |} : int * int -> int) ] [%Michelson ({| { UNPAIR ; ADD } |} : int * int -> int) ]
...@@ -8,6 +10,6 @@ module C = struct ...@@ -8,6 +10,6 @@ module C = struct
end end
let test = let test =
let orig = Test.originate (contract_of C) 1 0tez in let orig = Test.Originate.contract (contract_of C) 1 0tez in
let _ = Test.transfer_exn orig.addr (Main 41) 0tez in let _ = Test.Typed_address.transfer_exn orig.taddr (Main 41) 0tez in
Test.log (Test.get_storage orig.addr) Test.IO.log (Test.Typed_address.get_storage orig.taddr)
let assert = Assert.assert
module C = struct module C = struct
type storage = int list type storage = int list
type parameter = bool type parameter = bool
...@@ -14,14 +16,14 @@ let test = ...@@ -14,14 +16,14 @@ let test =
if p = 0 then acc else aux (p::acc) (p-1) if p = 0 then acc else aux (p::acc) (p-1)
in aux ([]:int list) 2000 in aux ([]:int list) 2000
in 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 = let _caching =
(* some caching is happening on the first transaction *) (* 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 in
let tx1 = Test.transfer orig.addr (Main false) 0tez in let tx1 = Test.Next.Typed_address.transfer orig.taddr (Main false) 0tez in
let tx2 = Test.transfer orig.addr (Main true) 0tez in let tx2 = Test.Next.Typed_address.transfer orig.taddr (Main true) 0tez in
let tx3 = Test.transfer orig.addr (Main true) 0tez in let tx3 = Test.Next.Typed_address.transfer orig.taddr (Main true) 0tez in
match (tx1 , tx2, tx3) with match (tx1 , tx2, tx3) with
| Success cons1 , Success cons2, Success cons3 -> | Success cons1 , Success cons2, Success cons3 ->
let () = assert ((cons1 < cons2) && (cons2 = cons3)) in let () = assert ((cons1 < cons2) && (cons2 = cons3)) in
......
module Test = Test.Next
module C = struct module C = struct
type parameter = Foo of int | Bar of nat type parameter = Foo of int | Bar of nat
...@@ -8,13 +10,13 @@ module C = struct ...@@ -8,13 +10,13 @@ module C = struct
end end
let test = let test =
let orig = Test.originate (contract_of C) 0 0tez in let orig = Test.Originate.contract (contract_of C) 0 0tez in
let ta = orig.addr in let ta = orig.taddr in
let c = Test.to_contract ta in let c = Test.Typed_address.to_contract ta in
let a = Tezos.address c 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 _ = (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 a : ((C parameter_of) contract)) in
let _ = (Tezos.get_contract_with_error a "foo" : ((C parameter_of) contract)) in let _ = (Tezos.get_contract_with_error a "foo" : ((C parameter_of) contract)) in
() ()
#import "main.mligo" "Main" #import "main.mligo" "Main"
module Test = Test.Next
let test1 = let test1 =
let _ = Test.originate (contract_of Main) "a" 1tez in let _ = Test.Originate.contract (contract_of Main) "a" 1tez in
() ()
\ No newline at end of file
module Test = Test.Next
let assert = Test.Assert.assert
let test_lambda_call = let test_lambda_call =
let a = 3 in let a = 3 in
let foo = fun (i : int) -> i * i in let foo = fun (i : int) -> i * i in
...@@ -374,19 +378,19 @@ let test_bytes_sub = ...@@ -374,19 +378,19 @@ let test_bytes_sub =
assert (Bytes.sub 0n 1n (Bytes.pack 5n) = 0x05) assert (Bytes.sub 0n 1n (Bytes.pack 5n) = 0x05)
let test_with_error = let test_with_error =
assert_with_error true "foo" Assert.Error.assert true "foo"
let test_some = let test_some =
assert_some (Some 1 : int option) Assert.some (Some 1 : int option)
let test_some_with_error = 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 = let test_none =
assert_none (None : int option) Assert.none (None : int option)
let test_none_with_error = let test_none_with_error =
assert_none_with_error (None : int option) "bar" Assert.Error.none (None : int option) "bar"
let test_unopt = let test_unopt =
assert (Option.value_with_error "option is None" (Some 1 : int option) = 1) assert (Option.value_with_error "option is None" (Some 1 : int option) = 1)
...@@ -398,7 +402,7 @@ let test_sha256 = ...@@ -398,7 +402,7 @@ let test_sha256 =
let hash5n = (0xf6c5c0ad2216920e105be5e940c4a71ead0741f9dbdb32bfab9570df57cc983a : bytes) in let hash5n = (0xf6c5c0ad2216920e105be5e940c4a71ead0741f9dbdb32bfab9570df57cc983a : bytes) in
let hashempty = (0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 : bytes) in let hashempty = (0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 : bytes) in
let () = assert (Crypto.sha256 (Bytes.pack 5n) = hash5n) 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) assert (Crypto.sha256 (Bytes.sub 0n 0n (Bytes.pack 5n)) = hashempty)
let test_sha512 = let test_sha512 =
...@@ -407,34 +411,34 @@ let test_sha512 = ...@@ -407,34 +411,34 @@ let test_sha512 =
let hashempty = let hashempty =
(0xcf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e : bytes) in (0xcf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e : bytes) in
let () = assert (Crypto.sha512 (Bytes.pack 5n) = hash5n) 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) assert (Crypto.sha512 (Bytes.sub 0n 0n (Bytes.pack 5n)) = hashempty)
let test_blake2b = let test_blake2b =
let hash5n = (0x2af6f7eb61511de4fa3a667a63e2f26f9c506042b335e62fed916335d04a08ed : bytes) in let hash5n = (0x2af6f7eb61511de4fa3a667a63e2f26f9c506042b335e62fed916335d04a08ed : bytes) in
let hashempty = (0x0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8 : bytes) in let hashempty = (0x0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8 : bytes) in
let () = assert (Crypto.blake2b (Bytes.pack 5n) = hash5n) 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) assert (Crypto.blake2b (Bytes.sub 0n 0n (Bytes.pack 5n)) = hashempty)
let test_keccak = let test_keccak =
let hash5n = (0xb40da68da4779bf68d31e6ab2eb21c26d950cc23e13efb4da0ec424f138000c3 : bytes) in let hash5n = (0xb40da68da4779bf68d31e6ab2eb21c26d950cc23e13efb4da0ec424f138000c3 : bytes) in
let hashempty = (0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 : bytes) in let hashempty = (0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 : bytes) in
let () = assert (Crypto.keccak (Bytes.pack 5n) = hash5n) 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) assert (Crypto.keccak (Bytes.sub 0n 0n (Bytes.pack 5n)) = hashempty)
let test_sha3 = let test_sha3 =
let hash5n = (0xfe2ecff30c0281f99ad639b9cfa50970ee98b382fa1688cef0bd33c7f5b0be16 : bytes) in let hash5n = (0xfe2ecff30c0281f99ad639b9cfa50970ee98b382fa1688cef0bd33c7f5b0be16 : bytes) in
let hashempty = (0xa7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a : bytes) in let hashempty = (0xa7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a : bytes) in
let () = assert (Crypto.sha3 (Bytes.pack 5n) = hash5n) 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) assert (Crypto.sha3 (Bytes.sub 0n 0n (Bytes.pack 5n)) = hashempty)
let test_key_hash = let test_key_hash =
let key = ("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav" : key) in let key = ("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav" : key) in
let key_hash = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : key_hash) 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) assert (Crypto.hash_key key = key_hash)
let test_check = let test_check =
...@@ -448,16 +452,16 @@ let test_check = ...@@ -448,16 +452,16 @@ let test_check =
let test_int_bls = let test_int_bls =
let alpha = (0xe406000000000000000000000000000000000000000000000000000000000000 : bls12_381_fr) in let alpha = (0xe406000000000000000000000000000000000000000000000000000000000000 : bls12_381_fr) in
let alpha_int = int alpha in let alpha_int = int alpha in
let mich_int = Test.run (fun (_ : unit) -> int (0xe406000000000000000000000000000000000000000000000000000000000000 : bls12_381_fr)) () in let mich_int = Test.Michelson.run (fun (_ : unit) -> int (0xe406000000000000000000000000000000000000000000000000000000000000 : bls12_381_fr)) () in
assert (Test.eval alpha_int = mich_int) assert (Test.Michelson.eval alpha_int = mich_int)
let test_not = let test_not =
let f ((x, y) : nat * int) : int = x * not y in 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 test_chain_id =
let chain_id = Test.eval ("NetXH12Aer3be93" : chain_id) in let chain_id = Test.Michelson.eval ("NetXH12Aer3be93" : chain_id) in
assert (chain_id = Test.eval (Tezos.get_chain_id ())) assert (chain_id = Test.Michelson.eval (Tezos.get_chain_id ()))
let test_concats = let test_concats =
let ss = ["aa"; "bb"; ""; "cc"] in let ss = ["aa"; "bb"; ""; "cc"] in
...@@ -466,8 +470,8 @@ let test_concats = ...@@ -466,8 +470,8 @@ let test_concats =
let () = assert (Bytes.concats bs = (0x00010203 : bytes)) in let () = assert (Bytes.concats bs = (0x00010203 : bytes)) in
let () = assert (String.concats [] = "") in let () = assert (String.concats [] = "") in
let () = assert (Bytes.concats [] = Bytes.sub 0n 0n (0x00 : bytes)) 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.Michelson.run (fun () -> String.concats ss) () = Test.Michelson.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 () -> Bytes.concats bs) () = Test.Michelson.eval (Bytes.concats bs)) in
() ()
let test_bytes_nat_int_conversion = let test_bytes_nat_int_conversion =
......
module Test = Test.Next
type parameter = One | Two type parameter = One | Two
type some_record = { a : int ; b : nat ; c : string } type some_record = { a : int ; b : nat ; c : string }
...@@ -6,6 +8,6 @@ let () = ...@@ -6,6 +8,6 @@ let () =
let v1 = { a= 1 ; b = 2n ; c = "aaa" } in let v1 = { a= 1 ; b = 2n ; c = "aaa" } in
let v2 = One in let v2 = One in
begin begin
Test.log v1 ; Test.IO.log v1 ;
Test.log v2 Test.IO.log v2
end end
let assert = Assert.assert
type storage = { type storage = {
tokenPool : nat ; tokenPool : nat ;
cashPool : nat ; cashPool : nat ;
...@@ -9,7 +11,7 @@ type storage = { ...@@ -9,7 +11,7 @@ type storage = {
lqtAddress : address ; lqtAddress : address ;
} }
let initial_storage = let initial_storage =
{ tokenPool = 103n ; { tokenPool = 103n ;
cashPool = 204n ; cashPool = 204n ;
lqtTotal = 10n ; lqtTotal = 10n ;
......