ligo/src/bin/expect_tests/contract_tests.ml

1343 lines
52 KiB
OCaml
Raw Normal View History

2019-11-22 00:06:34 +04:00
open Cli_expect
let contract basename =
"../../test/contracts/" ^ basename
2020-01-20 22:40:45 +04:00
let bad_contract basename =
"../../test/contracts/negative/" ^ basename
2019-11-22 00:06:34 +04:00
2019-11-26 03:30:12 +04:00
let%expect_test _ =
run_ligo_good [ "measure-contract" ; contract "coase.ligo" ; "main" ] ;
2020-03-16 21:34:43 +04:00
[%expect {| 1872 bytes |}] ;
2019-11-26 03:30:12 +04:00
run_ligo_good [ "measure-contract" ; contract "multisig.ligo" ; "main" ] ;
[%expect {| 1294 bytes |}] ;
2019-11-26 03:30:12 +04:00
run_ligo_good [ "measure-contract" ; contract "multisig-v2.ligo" ; "main" ] ;
2020-03-27 18:23:55 +04:00
[%expect {| 2974 bytes |}] ;
2019-11-26 03:30:12 +04:00
run_ligo_good [ "measure-contract" ; contract "vote.mligo" ; "main" ] ;
2020-03-02 21:01:56 +04:00
[%expect {| 589 bytes |}] ;
2019-11-26 03:30:12 +04:00
2019-12-18 19:35:17 +04:00
run_ligo_good [ "compile-parameter" ; contract "coase.ligo" ; "main" ; "Buy_single (record card_to_buy = 1n end)" ] ;
[%expect {| (Left (Left 1)) |}] ;
run_ligo_good [ "compile-storage" ; contract "coase.ligo" ; "main" ; "record cards = (map end : cards) ; card_patterns = (map end : card_patterns) ; next_id = 3n ; end" ] ;
[%expect {| (Pair (Pair {} {}) 3) |}] ;
run_ligo_bad [ "compile-storage" ; contract "coase.ligo" ; "main" ; "Buy_single (record card_to_buy = 1n end)" ] ;
2020-01-08 14:54:21 +04:00
[%expect {|
ligo: different kinds: {"a":"record[card_patterns -> (TO_Map (nat,record[coefficient -> mutez , quantity -> nat])) ,\n cards -> (TO_Map (nat,record[card_owner -> address , card_pattern -> nat])) ,\n next_id -> nat]","b":"sum[Buy_single -> record[card_to_buy -> nat] ,\n Sell_single -> record[card_to_sell -> nat] ,\n Transfer_single -> record[card_to_transfer -> nat ,\n destination -> address]]"}
2020-01-08 14:54:21 +04:00
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}] ;
2019-12-18 19:35:17 +04:00
run_ligo_bad [ "compile-parameter" ; contract "coase.ligo" ; "main" ; "record cards = (map end : cards) ; card_patterns = (map end : card_patterns) ; next_id = 3n ; end" ] ;
2020-01-08 14:54:21 +04:00
[%expect {|
ligo: different kinds: {"a":"sum[Buy_single -> record[card_to_buy -> nat] ,\n Sell_single -> record[card_to_sell -> nat] ,\n Transfer_single -> record[card_to_transfer -> nat ,\n destination -> address]]","b":"record[card_patterns -> (TO_Map (nat,record[coefficient -> mutez , quantity -> nat])) ,\n cards -> (TO_Map (nat,record[card_owner -> address , card_pattern -> nat])) ,\n next_id -> nat]"}
2020-01-08 14:54:21 +04:00
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}] ;
2019-12-18 19:35:17 +04:00
2019-11-26 03:30:12 +04:00
()
let%expect_test _ =
run_ligo_good [ "compile-storage" ; contract "timestamp.ligo" ; "main" ; "now" ; "--predecessor-timestamp" ; "2042-01-01T00:00:00Z" ] ;
[%expect {| "2042-01-01T00:00:01Z" |}]
2019-11-26 03:30:12 +04:00
let%expect_test _ =
2019-11-22 00:06:34 +04:00
run_ligo_good [ "compile-contract" ; contract "coase.ligo" ; "main" ] ;
[%expect {|
{ parameter
(or (or (nat %buy_single) (nat %sell_single))
(pair %transfer_single (nat %card_to_transfer) (address %destination))) ;
storage
(pair (pair (map %card_patterns nat (pair (mutez %coefficient) (nat %quantity)))
(map %cards nat (pair (address %card_owner) (nat %card_pattern))))
(nat %next_id)) ;
2019-11-26 03:15:25 +04:00
code { DUP ;
CDR ;
DIP { DUP } ;
SWAP ;
CAR ;
IF_LEFT
{ DUP ;
IF_LEFT
{ DUP ;
DIP { DIP 2 { DUP } ; DIG 2 } ;
PAIR ;
DUP ;
CAR ;
DIP { DUP } ;
SWAP ;
CDR ;
DIP { DUP } ;
SWAP ;
DIP { DUP ; CAR ; CAR } ;
GET ;
IF_NONE
{ PUSH string "buy_single: No card pattern." ; FAILWITH }
{ DUP ; DIP { DROP } } ;
2019-11-26 03:15:25 +04:00
DUP ;
CAR ;
DIP { DUP ; CDR ; PUSH nat 1 ; ADD } ;
MUL ;
DUP ;
AMOUNT ;
SWAP ;
COMPARE ;
GT ;
IF { PUSH string "Not enough money" ; FAILWITH } { PUSH unit Unit } ;
DIP 2 { DUP } ;
DIG 2 ;
2019-12-04 21:30:52 +04:00
DIP 3 { DUP } ;
DIG 3 ;
2019-11-26 03:15:25 +04:00
CDR ;
PUSH nat 1 ;
ADD ;
SWAP ;
CAR ;
PAIR ;
DIP 4 { DUP } ;
DIG 4 ;
2019-12-04 21:30:52 +04:00
DIP 6 { DUP } ;
DIG 6 ;
DIP { DIP { DUP } ;
SWAP ;
SOME ;
DIP { DIP 5 { DUP } ; DIG 5 ; CAR ; CAR } } ;
2019-11-26 03:15:25 +04:00
UPDATE ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CDR ; SWAP ; CAR ; CDR } ;
PAIR ;
PAIR ;
2019-11-26 03:15:25 +04:00
DUP ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
CDR ;
DIP { DIP 7 { DUP } ;
DIG 7 ;
2020-01-21 12:24:16 +04:00
SENDER ;
2019-12-04 21:30:52 +04:00
PAIR ;
SOME ;
DIP { DIP { DUP } ; SWAP ; CAR ; CDR } } ;
UPDATE ;
DIP { DUP ; CDR ; SWAP ; CAR ; CAR } ;
2019-11-26 03:15:25 +04:00
SWAP ;
PAIR ;
PAIR ;
2019-12-04 21:30:52 +04:00
DUP ;
DIP { DUP } ;
SWAP ;
2019-11-26 03:15:25 +04:00
CDR ;
PUSH nat 1 ;
ADD ;
SWAP ;
2019-12-04 21:30:52 +04:00
CAR ;
2019-11-26 03:15:25 +04:00
PAIR ;
2019-12-04 21:30:52 +04:00
DUP ;
NIL operation ;
2019-11-26 03:15:25 +04:00
PAIR ;
2019-12-04 21:30:52 +04:00
DIP { DROP 11 } }
2019-11-26 03:15:25 +04:00
{ DUP ;
DIP { DIP 2 { DUP } ; DIG 2 } ;
PAIR ;
DUP ;
CAR ;
DIP { DUP } ;
SWAP ;
CDR ;
DIP { DUP } ;
SWAP ;
DIP { DUP ; CAR ; CDR } ;
GET ;
IF_NONE
{ PUSH string "sell_single: No card." ; FAILWITH }
{ DUP ; DIP { DROP } } ;
2019-11-26 03:15:25 +04:00
DUP ;
CAR ;
2020-01-21 12:24:16 +04:00
SENDER ;
2019-11-26 03:15:25 +04:00
SWAP ;
COMPARE ;
NEQ ;
IF { PUSH string "This card doesn't belong to you" ; FAILWITH }
{ PUSH unit Unit } ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
2019-11-26 03:15:25 +04:00
CDR ;
2019-12-04 21:30:52 +04:00
DIP { DIP 2 { DUP } ; DIG 2 ; CAR ; CAR } ;
2019-11-26 03:15:25 +04:00
GET ;
IF_NONE
{ PUSH string "sell_single: No card pattern." ; FAILWITH }
{ DUP ; DIP { DROP } } ;
2019-11-26 03:15:25 +04:00
DUP ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
2019-11-26 03:15:25 +04:00
CDR ;
PUSH nat 1 ;
SWAP ;
SUB ;
ABS ;
SWAP ;
CAR ;
PAIR ;
2019-12-04 21:30:52 +04:00
DIP 4 { DUP } ;
DIG 4 ;
DIP 4 { DUP } ;
DIG 4 ;
2019-11-26 03:15:25 +04:00
CDR ;
2019-12-04 21:30:52 +04:00
DIP { DIP { DUP } ;
SWAP ;
SOME ;
DIP { DIP 5 { DUP } ; DIG 5 ; CAR ; CAR } } ;
2019-11-26 03:15:25 +04:00
UPDATE ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CDR ; SWAP ; CAR ; CDR } ;
2019-11-26 03:15:25 +04:00
PAIR ;
PAIR ;
2019-12-04 21:30:52 +04:00
DIP 6 { DUP } ;
DIG 6 ;
DIP { DUP ; CAR ; CDR ; NONE (pair (address %card_owner) (nat %card_pattern)) } ;
UPDATE ;
2019-11-26 03:15:25 +04:00
DIP 2 { DUP } ;
DIG 2 ;
CAR ;
DIP { DIP 2 { DUP } ; DIG 2 ; CDR } ;
MUL ;
2020-01-21 12:24:16 +04:00
SENDER ;
2019-11-26 03:15:25 +04:00
CONTRACT unit ;
IF_NONE
{ PUSH string "sell_single: No contract." ; FAILWITH }
{ DUP ; DIP { DROP } } ;
2019-11-26 03:15:25 +04:00
DIP { DUP } ;
SWAP ;
DIP { DUP } ;
UNIT ;
TRANSFER_TOKENS ;
DUP ;
NIL operation ;
SWAP ;
CONS ;
2020-03-16 21:34:43 +04:00
DUP ;
DIP { DIP 5 { DUP } ;
DIG 5 ;
DIP 5 { DUP } ;
DIG 5 ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CDR ; SWAP ; CAR ; CAR } ;
SWAP ;
PAIR ;
PAIR } ;
2019-11-26 03:15:25 +04:00
PAIR ;
2020-03-16 21:34:43 +04:00
DIP { DROP 14 } } ;
2019-11-26 03:15:25 +04:00
DIP { DROP } }
2019-11-22 00:06:34 +04:00
{ DUP ;
2019-11-26 03:15:25 +04:00
DIP { DIP { DUP } ; SWAP } ;
PAIR ;
DUP ;
2019-11-22 00:06:34 +04:00
CAR ;
DIP { DUP } ;
SWAP ;
CDR ;
DUP ;
CAR ;
CDR ;
DIP 2 { DUP } ;
DIG 2 ;
CAR ;
DIP { DUP } ;
GET ;
IF_NONE
{ PUSH string "transfer_single: No card." ; FAILWITH }
{ DUP ; DIP { DROP } } ;
2019-11-22 00:06:34 +04:00
DUP ;
CAR ;
2020-01-21 12:24:16 +04:00
SENDER ;
2019-11-22 00:06:34 +04:00
SWAP ;
COMPARE ;
NEQ ;
IF { PUSH string "This card doesn't belong to you" ; FAILWITH }
{ PUSH unit Unit } ;
DIP 3 { DUP } ;
DIG 3 ;
2019-12-04 21:30:52 +04:00
DIP 5 { DUP } ;
DIG 5 ;
2019-11-22 00:06:34 +04:00
CAR ;
2019-12-04 21:30:52 +04:00
DIP { DIP 2 { DUP } ;
DIG 2 ;
DIP 6 { DUP } ;
DIG 6 ;
CDR ;
SWAP ;
CDR ;
SWAP ;
PAIR ;
SOME ;
DIP { DIP 3 { DUP } ; DIG 3 } } ;
2019-11-22 00:06:34 +04:00
UPDATE ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CDR ; SWAP ; CAR ; CAR } ;
2019-11-22 00:06:34 +04:00
SWAP ;
PAIR ;
PAIR ;
NIL operation ;
PAIR ;
2019-12-04 21:30:52 +04:00
DIP { DROP 7 } } ;
2019-11-26 03:15:25 +04:00
DIP { DROP 2 } } } |} ]
2019-11-26 03:30:12 +04:00
let%expect_test _ =
run_ligo_good [ "compile-contract" ; contract "multisig.ligo" ; "main" ] ;
[%expect {|
{ parameter
(pair (pair (nat %counter) (lambda %message unit (list operation)))
2019-12-04 21:30:52 +04:00
(list %signatures (pair (key_hash %0) (signature %1)))) ;
2019-11-26 03:30:12 +04:00
storage
(pair (pair (list %auth key) (nat %counter)) (pair (string %id) (nat %threshold))) ;
code { DUP ;
CAR ;
2019-11-26 03:15:25 +04:00
DIP { DUP ; CDR } ;
PAIR ;
DUP ;
CAR ;
DIP { DUP } ;
SWAP ;
2019-11-26 03:30:12 +04:00
CDR ;
DIP { DUP } ;
SWAP ;
2019-11-26 03:15:25 +04:00
CAR ;
CDR ;
DIP { DUP } ;
SWAP ;
2019-12-04 21:30:52 +04:00
DIP 3 { DUP } ;
DIG 3 ;
2019-11-26 03:15:25 +04:00
CAR ;
CAR ;
2019-12-04 21:30:52 +04:00
DIP { DIP 2 { DUP } ; DIG 2 ; CAR ; CDR } ;
2019-11-26 03:15:25 +04:00
COMPARE ;
NEQ ;
IF { PUSH string "Counters does not match" ; FAILWITH }
2019-12-04 21:30:52 +04:00
{ DIP 3 { DUP } ;
2019-11-26 03:15:25 +04:00
DIG 3 ;
CDR ;
2019-12-04 21:30:52 +04:00
DIP { DIP 2 { DUP } ; DIG 2 ; CAR ; CAR ; PUSH nat 0 ; SWAP ; PAIR } ;
2019-11-26 03:15:25 +04:00
ITER { SWAP ;
PAIR ;
DUP ;
CAR ;
CDR ;
2019-11-26 03:15:25 +04:00
DIP { DUP } ;
SWAP ;
CAR ;
CAR ;
2019-12-04 21:30:52 +04:00
DIP 2 { DUP } ;
DIG 2 ;
CDR ;
DIP { DUP } ;
SWAP ;
DIP { DIP 2 { DUP } ; DIG 2 } ;
PAIR ;
2019-12-04 21:30:52 +04:00
DIP 2 { DUP } ;
DIG 2 ;
2019-11-26 03:15:25 +04:00
IF_CONS
{ DIP 5 { DUP } ;
DIG 5 ;
2019-12-04 21:30:52 +04:00
DIP 4 { DUP } ;
DIG 4 ;
2019-11-26 03:15:25 +04:00
CAR ;
2019-12-04 21:30:52 +04:00
DIP { DIP { DUP } ; SWAP ; HASH_KEY } ;
2019-11-26 03:15:25 +04:00
COMPARE ;
EQ ;
IF { DIP 6 { DUP } ;
DIG 6 ;
2019-12-04 21:30:52 +04:00
DIP 2 { DUP } ;
DIG 2 ;
DIP { DIP 5 { DUP } ;
DIG 5 ;
CDR ;
DIP { DIP 10 { DUP } ;
DIG 10 ;
DIP { DIP 12 { DUP } ; DIG 12 ; CAR ; CAR } ;
PAIR ;
DIP { DIP 11 { DUP } ; DIG 11 ; CDR ; CAR ; CHAIN_ID ; SWAP ; PAIR } ;
PAIR ;
PACK } } ;
2019-11-26 03:15:25 +04:00
CHECK_SIGNATURE ;
IF { DIP 7 { DUP } ;
DIG 7 ;
2019-11-26 03:15:25 +04:00
PUSH nat 1 ;
ADD ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
DIP { DUP } ;
2019-11-26 03:15:25 +04:00
SWAP ;
2019-12-04 21:30:52 +04:00
DIP { DROP 2 } }
{ PUSH string "Invalid signature" ; FAILWITH } ;
DIP 2 { DUP } ;
DIG 2 ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
DIP { DROP 3 } }
2019-12-04 21:30:52 +04:00
{ DUP } ;
DIP 4 { DUP } ;
DIG 4 ;
DIP 4 { DUP } ;
DIG 4 ;
2019-12-04 21:30:52 +04:00
SWAP ;
CDR ;
SWAP ;
PAIR ;
CAR ;
DIP { DUP } ;
PAIR ;
DIP { DROP 4 } }
2019-12-04 21:30:52 +04:00
{ DUP } ;
DIP 5 { DUP } ;
DIG 5 ;
DIP 6 { DUP } ;
DIG 6 ;
2019-12-04 21:30:52 +04:00
CAR ;
DIP 2 { DUP } ;
DIG 2 ;
CAR ;
SWAP ;
2019-12-04 21:30:52 +04:00
CDR ;
SWAP ;
PAIR ;
SWAP ;
CDR ;
SWAP ;
PAIR ;
DUP ;
2019-11-26 03:15:25 +04:00
DIP { DUP } ;
SWAP ;
2019-12-04 21:30:52 +04:00
CAR ;
DIP 3 { DUP } ;
DIG 3 ;
CDR ;
SWAP ;
CAR ;
2019-12-04 21:30:52 +04:00
PAIR ;
SWAP ;
CDR ;
SWAP ;
PAIR ;
CAR ;
DIP { DROP 7 } } ;
2019-12-04 21:30:52 +04:00
DIP 3 { DUP } ;
DIG 3 ;
2019-11-26 03:15:25 +04:00
DIP { DUP } ;
SWAP ;
2019-12-04 21:30:52 +04:00
CDR ;
2019-11-26 03:15:25 +04:00
DIP { DIP 4 { DUP } ; DIG 4 ; CDR ; CDR } ;
COMPARE ;
LT ;
IF { PUSH string "Not enough signatures passed the check" ; FAILWITH }
{ DIP 4 { DUP } ;
DIG 4 ;
2019-12-04 21:30:52 +04:00
DIP 5 { DUP } ;
DIG 5 ;
2019-11-26 03:15:25 +04:00
CAR ;
CDR ;
PUSH nat 1 ;
ADD ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CDR ; SWAP ; CAR ; CAR } ;
2019-11-26 03:15:25 +04:00
SWAP ;
PAIR ;
PAIR ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
DIP { DUP } ;
SWAP ;
DIP { DROP 2 } } ;
DIP 3 { DUP } ;
DIG 3 ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
DIP { DROP 4 } } ;
DIP 2 { DUP } ;
DIG 2 ;
2019-11-26 03:15:25 +04:00
UNIT ;
EXEC ;
DIP { DUP } ;
2019-11-26 03:30:12 +04:00
PAIR ;
DIP { DROP 7 } } } |} ]
2019-11-26 03:30:12 +04:00
let%expect_test _ =
run_ligo_good [ "compile-contract" ; contract "multisig-v2.ligo" ; "main" ] ;
[%expect {|
{ parameter
(or (or (unit %default) (lambda %send bytes (list operation)))
(lambda %withdraw bytes (list operation))) ;
2019-11-26 03:30:12 +04:00
storage
(pair (pair (pair (set %authorized_addresses address) (nat %max_message_size))
(pair (nat %max_proposal) (map %message_store bytes (set address))))
(pair (pair (map %proposal_counters address nat) (bytes %state_hash))
(nat %threshold))) ;
2019-11-26 03:30:12 +04:00
code { DUP ;
CDR ;
DIP { DUP } ;
SWAP ;
2019-11-26 03:15:25 +04:00
CAR ;
IF_LEFT
{ DUP ;
IF_LEFT
{ DIP 2 { DUP } ; DIG 2 ; NIL operation ; PAIR ; DIP { DROP } }
{ DUP ;
DIP { DIP 2 { DUP } ; DIG 2 } ;
PAIR ;
DUP ;
CDR ;
DUP ;
CAR ;
CAR ;
CAR ;
SENDER ;
MEM ;
NOT ;
IF { PUSH string "Unauthorized address" ; FAILWITH } { PUSH unit Unit } ;
2019-12-04 21:30:52 +04:00
DIP 2 { DUP } ;
DIG 2 ;
CAR ;
DUP ;
PACK ;
DUP ;
SIZE ;
2019-12-04 21:30:52 +04:00
DIP { DIP 3 { DUP } ; DIG 3 ; CAR ; CAR ; CDR } ;
COMPARE ;
GT ;
IF { PUSH string "Message size exceed maximum limit" ; FAILWITH }
{ PUSH unit Unit } ;
EMPTY_SET address ;
2020-03-16 21:34:43 +04:00
DUP ;
DIP { DIP 5 { DUP } ; DIG 5 } ;
2019-12-04 21:30:52 +04:00
PAIR ;
2020-03-16 21:34:43 +04:00
DIP 3 { DUP } ;
DIG 3 ;
DIP { DIP 6 { DUP } ; DIG 6 ; CAR ; CDR ; CDR } ;
GET ;
IF_NONE
2020-03-16 21:34:43 +04:00
{ DIP 6 { DUP } ;
2019-12-04 21:30:52 +04:00
DIG 6 ;
2020-03-16 21:34:43 +04:00
DIP 7 { DUP } ;
DIG 7 ;
CDR ;
CAR ;
CAR ;
SENDER ;
GET ;
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
PUSH nat 1 ;
ADD ;
SOME ;
2020-03-16 21:34:43 +04:00
DIP { DIP 7 { DUP } ; DIG 7 ; CDR ; CAR ; CAR } ;
SENDER ;
UPDATE ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
PAIR ;
PAIR ;
SWAP ;
PAIR ;
EMPTY_SET address ;
PUSH bool True ;
SENDER ;
UPDATE ;
2020-03-16 21:34:43 +04:00
DIP 2 { DUP } ;
DIG 2 ;
DIP 2 { DUP } ;
DIG 2 ;
2019-12-04 21:30:52 +04:00
SWAP ;
2020-03-16 21:34:43 +04:00
CAR ;
PAIR ;
2019-12-04 21:30:52 +04:00
CDR ;
2020-03-16 21:34:43 +04:00
DIP { DUP } ;
2019-12-04 21:30:52 +04:00
SWAP ;
PAIR ;
2020-03-16 21:34:43 +04:00
DIP { DROP 2 } }
{ DIP 7 { DUP } ;
DIG 7 ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
SENDER ;
MEM ;
2019-12-04 21:30:52 +04:00
IF { DUP }
2020-03-16 21:34:43 +04:00
{ DIP 8 { DUP } ;
2019-12-04 21:30:52 +04:00
DIG 8 ;
2020-03-16 21:34:43 +04:00
DIP 9 { DUP } ;
DIG 9 ;
CDR ;
CAR ;
CAR ;
SENDER ;
GET ;
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
PUSH nat 1 ;
ADD ;
SOME ;
2020-03-16 21:34:43 +04:00
DIP { DIP 9 { DUP } ; DIG 9 ; CDR ; CAR ; CAR } ;
SENDER ;
UPDATE ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
PAIR ;
PAIR ;
SWAP ;
PAIR ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
DIP { DUP } ;
SWAP ;
DIP { DROP 2 } } ;
DIP 3 { DUP } ;
DIG 3 ;
2019-12-04 21:30:52 +04:00
CAR ;
DIP { DUP } ;
PAIR ;
DIP 3 { DUP } ;
DIG 3 ;
PUSH bool True ;
SENDER ;
UPDATE ;
SWAP ;
2019-12-04 21:30:52 +04:00
CDR ;
SWAP ;
PAIR ;
DIP { DROP 3 } } ;
2019-12-04 21:30:52 +04:00
DUP ;
CAR ;
DIP { DUP } ;
SWAP ;
CDR ;
DUP ;
CDR ;
CAR ;
CAR ;
SENDER ;
GET ;
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
DUP ;
2019-12-04 21:30:52 +04:00
DIP { DIP { DUP } ; SWAP ; CAR ; CDR ; CAR } ;
COMPARE ;
GT ;
IF { PUSH string "Maximum number of proposal reached" ; FAILWITH }
{ PUSH unit Unit } ;
NIL operation ;
2020-03-27 18:23:55 +04:00
DUP ;
2020-03-16 21:34:43 +04:00
DIP { DIP 3 { DUP } ; DIG 3 } ;
PAIR ;
DIP 5 { DUP } ;
DIG 5 ;
SIZE ;
2020-03-16 21:34:43 +04:00
DIP { DIP 4 { DUP } ; DIG 4 ; CDR ; CDR } ;
COMPARE ;
GE ;
2020-03-16 21:34:43 +04:00
IF { DIP 4 { DUP } ;
DIG 4 ;
DIP 11 { DUP } ;
DIG 11 ;
DIP { DIP 5 { DUP } ; DIG 5 ; CAR ; CDR ; CDR ; NONE (set address) } ;
UPDATE ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; CAR } ;
SWAP ;
PAIR ;
SWAP ;
PAIR ;
PAIR ;
2019-12-04 21:30:52 +04:00
DUP ;
CDR ;
CAR ;
CDR ;
2020-03-16 21:34:43 +04:00
DIP { DIP 12 { DUP } ; DIG 12 } ;
EXEC ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
DIP 2 { DUP } ;
DIG 2 ;
CDR ;
CAR ;
CDR ;
2020-03-16 21:34:43 +04:00
DIP { DIP 13 { DUP } ; DIG 13 } ;
CONCAT ;
SHA256 ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CAR } ;
SWAP ;
PAIR ;
PAIR ;
SWAP ;
PAIR ;
2019-12-04 21:30:52 +04:00
DUP ;
CDR ;
CAR ;
CAR ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
ITER { SWAP ;
PAIR ;
DUP ;
CAR ;
DIP { DUP } ;
SWAP ;
CDR ;
CAR ;
DIP { DUP } ;
SWAP ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
2020-03-27 18:23:55 +04:00
SWAP ;
DIP { DIP 12 { DUP } ; DIG 12 } ;
MEM ;
IF { DIP 2 { DUP } ;
DIG 2 ;
DIP 2 { DUP } ;
DIG 2 ;
DIP { DIP 4 { DUP } ;
DIG 4 ;
CDR ;
CDR ;
PUSH nat 1 ;
SWAP ;
SUB ;
ABS ;
SOME ;
DIP { DIP 3 { DUP } ; DIG 3 ; CDR ; CAR ; CAR } } ;
UPDATE ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
PAIR ;
PAIR ;
SWAP ;
PAIR ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
DIP { DUP } ;
SWAP ;
DIP { DROP 2 } }
2019-12-04 21:30:52 +04:00
{ DUP } ;
DIP 4 { DUP } ;
DIG 4 ;
2019-12-04 21:30:52 +04:00
DIP 5 { DUP } ;
DIG 5 ;
CAR ;
DIP 2 { DUP } ;
DIG 2 ;
2019-12-04 21:30:52 +04:00
DIP { DROP ; CDR } ;
PAIR ;
CAR ;
DIP { DROP 5 } } ;
2019-12-04 21:30:52 +04:00
DIP 4 { DUP } ;
DIG 4 ;
DIP 4 { DUP } ;
DIG 4 ;
SWAP ;
CAR ;
PAIR ;
DIP 3 { DUP } ;
DIG 3 ;
2019-12-04 21:30:52 +04:00
SWAP ;
CDR ;
2019-12-04 21:30:52 +04:00
SWAP ;
PAIR ;
DIP 2 { DUP } ;
DIG 2 ;
SWAP ;
CAR ;
PAIR ;
CAR ;
DIP { DUP } ;
PAIR ;
DIP { DROP 4 } }
{ DUP ;
2020-03-16 21:34:43 +04:00
DIP 5 { DUP } ;
DIG 5 ;
DIP 12 { DUP } ;
DIG 12 ;
DIP { DIP 7 { DUP } ;
DIG 7 ;
SOME ;
2020-03-16 21:34:43 +04:00
DIP { DIP 6 { DUP } ; DIG 6 ; CAR ; CDR ; CDR } } ;
UPDATE ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; CAR } ;
SWAP ;
PAIR ;
SWAP ;
PAIR ;
PAIR ;
2019-12-04 21:30:52 +04:00
SWAP ;
CAR ;
PAIR } ;
DUP ;
2019-12-04 21:30:52 +04:00
CAR ;
DIP { DUP ; CDR } ;
PAIR ;
2020-03-16 21:34:43 +04:00
DIP { DROP 17 } } ;
DIP { DROP } }
{ DUP ;
DIP { DIP { DUP } ; SWAP } ;
PAIR ;
DUP ;
CDR ;
DIP { DUP } ;
SWAP ;
CAR ;
PACK ;
DIP { DUP } ;
SWAP ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
DIP { DIP 2 { DUP } ; DIG 2 ; CAR ; CDR ; CDR } ;
GET ;
IF_NONE
2019-12-04 21:30:52 +04:00
{ DUP }
{ DUP ;
PUSH bool False ;
SENDER ;
UPDATE ;
2019-12-04 21:30:52 +04:00
DIP 4 { DUP } ;
DIG 4 ;
DIP 2 { DUP } ;
DIG 2 ;
SIZE ;
2019-12-04 21:30:52 +04:00
DIP { DIP { DUP } ; SWAP ; SIZE } ;
COMPARE ;
NEQ ;
2019-12-04 21:30:52 +04:00
IF { DIP 5 { DUP } ;
DIG 5 ;
DIP 6 { DUP } ;
DIG 6 ;
CDR ;
CAR ;
CAR ;
SENDER ;
GET ;
IF_NONE { PUSH string "MAP FIND" ; FAILWITH } {} ;
PUSH nat 1 ;
SWAP ;
SUB ;
ABS ;
SOME ;
2019-12-04 21:30:52 +04:00
DIP { DIP 6 { DUP } ; DIG 6 ; CDR ; CAR ; CAR } ;
SENDER ;
UPDATE ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
PAIR ;
PAIR ;
SWAP ;
PAIR ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
DIP { DUP } ;
SWAP ;
DIP { DROP 2 } }
{ DUP } ;
DUP ;
DUP ;
DIP 4 { DUP } ;
DIG 4 ;
SIZE ;
PUSH nat 0 ;
SWAP ;
COMPARE ;
EQ ;
2019-12-04 21:30:52 +04:00
IF { DIP { DUP } ;
SWAP ;
DIP 8 { DUP } ;
DIG 8 ;
2019-12-04 21:30:52 +04:00
DIP { DIP 2 { DUP } ; DIG 2 ; CAR ; CDR ; CDR ; NONE (set address) } ;
UPDATE ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; CAR } ;
SWAP ;
PAIR ;
SWAP ;
PAIR ;
PAIR ;
2019-12-04 21:30:52 +04:00
DIP { DUP } ;
SWAP ;
DIP { DUP } ;
SWAP ;
DIP { DROP 2 } }
2019-12-04 21:30:52 +04:00
{ DUP ;
DIP 2 { DUP } ;
DIG 2 ;
DIP 9 { DUP } ;
DIG 9 ;
DIP { DIP 6 { DUP } ;
DIG 6 ;
2019-12-04 21:30:52 +04:00
SOME ;
DIP { DIP 3 { DUP } ; DIG 3 ; CAR ; CDR ; CDR } } ;
UPDATE ;
2019-12-04 21:30:52 +04:00
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; CAR } ;
SWAP ;
PAIR ;
SWAP ;
PAIR ;
PAIR ;
DIP { DROP } } ;
DIP 7 { DUP } ;
DIG 7 ;
DIP 3 { DUP } ;
DIG 3 ;
DIP { DROP ; DUP } ;
2019-12-04 21:30:52 +04:00
SWAP ;
DIP { DROP 8 } } ;
2019-12-04 21:30:52 +04:00
DUP ;
NIL operation ;
PAIR ;
DIP { DROP 6 } } ;
DIP { DROP 2 } } } |} ]
2019-11-26 03:30:12 +04:00
let%expect_test _ =
run_ligo_good [ "compile-contract" ; contract "vote.mligo" ; "main" ] ;
[%expect {|
{ parameter
2020-03-02 21:01:56 +04:00
(or (pair %reset (pair (timestamp %finish_time) (timestamp %start_time)) (string %title))
(or %vote (unit %nay) (unit %yea))) ;
2019-11-26 03:30:12 +04:00
storage
2020-03-02 21:01:56 +04:00
(pair (pair (pair (timestamp %finish_time) (nat %nay))
(pair (timestamp %start_time) (string %title)))
(pair (set %voters address) (nat %yea))) ;
2019-11-26 03:15:25 +04:00
code { DUP ;
2020-03-02 21:01:56 +04:00
DUP ;
2019-11-26 03:15:25 +04:00
CAR ;
IF_LEFT
2019-11-26 03:30:12 +04:00
{ DUP ;
2019-11-26 04:10:49 +04:00
DUP ;
CAR ;
CAR ;
2020-03-02 21:01:56 +04:00
PUSH nat 0 ;
SWAP ;
2019-11-26 03:30:12 +04:00
PAIR ;
2020-03-02 21:01:56 +04:00
DIP { DUP ; CAR ; CDR ; DIP { DUP ; CDR } ; PAIR } ;
2019-11-26 03:30:12 +04:00
PAIR ;
2020-03-02 21:01:56 +04:00
DIP { PUSH nat 0 ; EMPTY_SET address ; PAIR } ;
2019-11-26 03:30:12 +04:00
PAIR ;
NIL operation ;
PAIR ;
2019-11-26 04:10:49 +04:00
DIP { DROP 2 } }
2019-11-26 03:30:12 +04:00
{ DUP ;
2019-11-26 03:15:25 +04:00
DIP { DIP { DUP } ; SWAP ; CDR } ;
PAIR ;
DUP ;
2020-03-02 21:01:56 +04:00
CDR ;
DIP { DUP } ;
SWAP ;
2019-11-26 03:30:12 +04:00
CAR ;
2020-03-02 21:01:56 +04:00
IF_LEFT
{ DIP { DUP } ;
SWAP ;
DIP 2 { DUP } ;
DIG 2 ;
CAR ;
CAR ;
CDR ;
PUSH nat 1 ;
ADD ;
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CDR ; SWAP ; CAR ; CAR } ;
SWAP ;
PAIR ;
PAIR ;
PAIR ;
DIP { DROP } }
{ DIP { DUP } ;
SWAP ;
DIP 2 { DUP } ;
DIG 2 ;
CDR ;
CDR ;
PUSH nat 1 ;
ADD ;
DIP { DUP ; CAR ; SWAP ; CDR ; CAR } ;
SWAP ;
PAIR ;
SWAP ;
PAIR ;
DIP { DROP } } ;
DUP ;
2019-11-26 04:10:49 +04:00
DIP { DUP } ;
SWAP ;
CDR ;
2019-11-26 03:30:12 +04:00
CAR ;
2020-03-02 21:01:56 +04:00
PUSH bool True ;
SENDER ;
UPDATE ;
DIP { DUP ; CAR ; SWAP ; CDR ; CDR } ;
2019-11-26 03:30:12 +04:00
PAIR ;
2020-03-02 21:01:56 +04:00
SWAP ;
2019-11-26 03:30:12 +04:00
PAIR ;
NIL operation ;
PAIR ;
2020-03-02 21:01:56 +04:00
DIP { DROP 4 } } ;
DIP { DROP 2 } } } |}]
let%expect_test _ =
run_ligo_good [ "compile-contract" ; contract "implicit.mligo" ; "main" ] ;
[%expect {|
{ parameter key_hash ;
storage unit ;
code { DUP ;
CAR ;
IMPLICIT_ACCOUNT ;
UNIT ;
NIL operation ;
PAIR ;
DIP { DROP 2 } } } |}]
2019-12-24 15:20:39 +04:00
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; contract "bad_type_operator.ligo" ; "main" ] ;
2020-01-08 14:54:21 +04:00
[%expect {|
ligo: bad type operator (TO_Map (unit,unit)):
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}]
let%expect_test _ =
2020-01-17 19:35:53 +04:00
run_ligo_good [ "run-function" ; contract "failwith.ligo" ; "failer" ; "1" ] ;
2020-01-08 14:54:21 +04:00
[%expect {|
2020-01-17 20:02:54 +04:00
failwith("some_string") |}]
2020-01-08 14:54:21 +04:00
2020-01-17 19:35:53 +04:00
let%expect_test _ =
run_ligo_good [ "run-function" ; contract "failwith.ligo" ; "failer" ; "1" ; "--format=json" ] ;
[%expect {|
2020-01-17 20:02:54 +04:00
{"status":"ok","content":"failwith(\"some_string\")"} |}]
2020-01-02 18:02:02 +04:00
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; contract "bad_address_format.religo" ; "main" ] ;
2020-01-08 14:54:21 +04:00
[%expect {|
2020-03-02 21:01:56 +04:00
ligo: in file "bad_address_format.religo", line 2, characters 26-48. Badly formatted literal: @"KT1badaddr" {"location":"in file \"bad_address_format.religo\", line 2, characters 26-48"}
2020-01-08 14:54:21 +04:00
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}]
2020-01-03 20:46:31 +04:00
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; contract "bad_timestamp.ligo" ; "main" ] ;
2020-01-08 14:54:21 +04:00
[%expect {|
ligo: in file "bad_timestamp.ligo", line 7, characters 30-44. Badly formatted timestamp "badtimestamp": {"location":"in file \"bad_timestamp.ligo\", line 7, characters 30-44"}
2020-01-08 14:54:21 +04:00
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}]
2020-01-06 21:51:43 +04:00
let%expect_test _ =
run_ligo_good [ "dry-run" ; contract "redeclaration.ligo" ; "main" ; "unit" ; "0" ] ;
2020-03-16 21:34:43 +04:00
[%expect {|( LIST_EMPTY() , 0 ) |}]
2020-01-06 21:51:43 +04:00
let%expect_test _ =
run_ligo_good [ "dry-run" ; contract "double_main.ligo" ; "main" ; "unit" ; "0" ] ;
2020-03-16 21:34:43 +04:00
[%expect {|( LIST_EMPTY() , 2 ) |}]
2020-01-07 00:19:14 +04:00
let%expect_test _ =
run_ligo_good [ "compile-contract" ; contract "subtle_nontail_fail.mligo" ; "main" ] ;
[%expect {|
{ parameter unit ;
storage unit ;
code { PUSH bool True ;
IF { PUSH string "This contract always fails" ; FAILWITH }
{ PUSH string "This contract still always fails" ; FAILWITH } } } |}]
let%expect_test _ =
(* TODO should not be bad? *)
2020-01-17 19:35:53 +04:00
run_ligo_good [ "dry-run" ; contract "subtle_nontail_fail.mligo" ; "main" ; "()" ; "()" ] ;
2020-01-07 00:19:14 +04:00
[%expect {|
2020-01-17 20:02:54 +04:00
failwith("This contract always fails") |}]
2020-01-07 00:19:14 +04:00
2020-01-20 22:40:45 +04:00
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; bad_contract "self_in_lambda.mligo" ; "main" ] ;
[%expect {|
ligo: Wrong SELF_ADDRESS location: SELF_ADDRESS is only allowed at top-level
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
2020-01-27 14:42:32 +04:00
* Check the changelog by running 'ligo changelog' |}]
let%expect_test _ =
run_ligo_good [ "compile-storage" ; contract "big_map.ligo" ; "main" ; "(big_map1,unit)" ] ;
[%expect {|
(Pair { Elt 23 0 ; Elt 42 0 } Unit) |}]
let%expect_test _ =
run_ligo_good [ "compile-contract" ; contract "key_hash_comparable.ligo" ; "main" ] ;
[%expect {|
{ parameter int ;
storage (pair (map %one key_hash nat) (big_map %two key_hash bool)) ;
code { DUP ; CDR ; NIL operation ; PAIR ; DIP { DROP } } } |}]
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; bad_contract "long_sum_type_names.ligo" ; "main" ] ;
[%expect {|
ligo: Too long constructor 'Incrementttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt': names length is limited to 32 (tezos limitation)
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}]
let%expect_test _ =
run_ligo_good [ "dry-run" ; contract "super-counter.mligo" ; "main" ; "test_param" ; "test_storage" ] ;
[%expect {|
2020-03-16 21:34:43 +04:00
( LIST_EMPTY() , 3 ) |}]
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; bad_contract "redundant_constructors.mligo" ; "main" ] ;
[%expect {|
ligo: redundant constructor: {"constructor":"Add","environment":"- E[]\tT[union_a -> sum[Add -> int , Remove -> int]] ]"}
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
2020-02-28 22:49:51 +04:00
* Check the changelog by running 'ligo changelog' |}]
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_toplevel.mligo" ; "main" ] ;
[%expect {|
ligo: in file "create_contract_toplevel.mligo", line 4, character 35 to line 8, character 8. No free variable allowed in this lambda: variable 'store' {"expression":"CREATE_CONTRACT(lambda (#P:Some(( nat * string ))) : None return\n let rhs#702 = #P in\n let p = rhs#702.0 in\n let s = rhs#702.1 in\n ( LIST_EMPTY() : (TO_list(operation)) , store ) ,\n NONE() : (TO_option(key_hash)) ,\n 300000000mutez ,\n \"un\")","location":"in file \"create_contract_toplevel.mligo\", line 4, character 35 to line 8, character 8"}
2020-02-28 22:49:51 +04:00
If you're not sure how to fix this error, you can
do one of the following:
2020-02-28 22:49:51 +04:00
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}] ;
2020-02-28 22:49:51 +04:00
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_var.mligo" ; "main" ] ;
[%expect {|
ligo: in file "create_contract_var.mligo", line 6, character 35 to line 10, character 5. No free variable allowed in this lambda: variable 'a' {"expression":"CREATE_CONTRACT(lambda (#P:Some(( nat * int ))) : None return\n let rhs#705 = #P in\n let p = rhs#705.0 in\n let s = rhs#705.1 in\n ( LIST_EMPTY() : (TO_list(operation)) , a ) ,\n NONE() : (TO_option(key_hash)) ,\n 300000000mutez ,\n 1)","location":"in file \"create_contract_var.mligo\", line 6, character 35 to line 10, character 5"}
2020-02-28 22:49:51 +04:00
If you're not sure how to fix this error, you can
do one of the following:
2020-02-28 22:49:51 +04:00
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}] ;
2020-03-02 15:53:10 +04:00
run_ligo_bad [ "compile-contract" ; bad_contract "create_contract_no_inline.mligo" ; "main" ] ;
[%expect {|
2020-03-04 03:10:52 +04:00
ligo: unbound type variable: {"variable":"return","in":"- E[foo -> int]\tT[] ]","did_you_mean":"no suggestion"}
2020-03-02 15:53:10 +04:00
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}] ;
2020-02-28 22:49:51 +04:00
run_ligo_good [ "compile-contract" ; contract "create_contract.mligo" ; "main" ] ;
[%expect {|
{ parameter string ;
storage string ;
code { PUSH string "un" ;
PUSH mutez 300000000 ;
NONE key_hash ;
CREATE_CONTRACT
{ parameter nat ;
storage string ;
code { PUSH string "one" ; NIL operation ; PAIR ; DIP { DROP } } } ;
PAIR ;
DUP ;
CAR ;
NIL operation ;
SWAP ;
CONS ;
DIP { DIP { DUP } ; SWAP ; CDR } ;
PAIR ;
DIP { DROP 2 } } } |}]
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; bad_contract "self_type_annotation.ligo" ; "main" ] ;
[%expect {|
ligo: in file "self_type_annotation.ligo", line 8, characters 41-64. bad self type: expected (TO_Contract (int)) but got (TO_Contract (nat)) {"location":"in file \"self_type_annotation.ligo\", line 8, characters 41-64"}
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}] ;
run_ligo_good [ "compile-contract" ; contract "self_type_annotation.ligo" ; "main" ] ;
[%expect {|
{ parameter nat ;
storage int ;
code { DUP ;
SELF %default ;
SWAP ;
CDR ;
NIL operation ;
PAIR ;
DIP { DROP 2 } } } |}]
let%expect_test _ =
run_ligo_bad [ "compile-contract" ; bad_contract "bad_contract.mligo" ; "main" ] ;
[%expect {|
ligo: in file "", line 0, characters 0-0. badly typed contract: unexpected entrypoint type {"location":"in file \"\", line 0, characters 0-0","entrypoint":"main","entrypoint_type":"( nat * int ) -> int"}
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}] ;
run_ligo_bad [ "compile-contract" ; bad_contract "bad_contract2.mligo" ; "main" ] ;
[%expect {|
ligo: in file "", line 0, characters 0-0. bad return type: expected (TO_list(operation)), got string {"location":"in file \"\", line 0, characters 0-0","entrypoint":"main"}
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}] ;
run_ligo_bad [ "compile-contract" ; bad_contract "bad_contract3.mligo" ; "main" ] ;
[%expect {|
ligo: in file "", line 0, characters 0-0. badly typed contract: expected {int} and {string} to be the same in the entrypoint type {"location":"in file \"\", line 0, characters 0-0","entrypoint":"main","entrypoint_type":"( nat * int ) -> ( (TO_list(operation)) * string )"}
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}]
let%expect_test _ =
run_ligo_good [ "compile-contract" ; contract "self_with_entrypoint.ligo" ; "main" ] ;
[%expect {|
{ parameter (or (unit %default) (int %toto)) ;
storage nat ;
code { SELF %toto ;
DUP ;
PUSH mutez 300000000 ;
PUSH int 2 ;
TRANSFER_TOKENS ;
DUP ;
NIL operation ;
SWAP ;
CONS ;
DIP { DIP 2 { DUP } ; DIG 2 ; CDR } ;
PAIR ;
DIP { DROP 3 } } } |}] ;
run_ligo_good [ "compile-contract" ; contract "self_without_entrypoint.ligo" ; "main" ] ;
[%expect {|
{ parameter int ;
storage nat ;
code { SELF %default ;
DUP ;
PUSH mutez 300000000 ;
PUSH int 2 ;
TRANSFER_TOKENS ;
DUP ;
NIL operation ;
SWAP ;
CONS ;
DIP { DIP 2 { DUP } ; DIG 2 ; CDR } ;
PAIR ;
DIP { DROP 3 } } } |}] ;
run_ligo_bad [ "compile-contract" ; bad_contract "self_bad_entrypoint_format.ligo" ; "main" ] ;
[%expect {|
ligo: in file "self_bad_entrypoint_format.ligo", line 8, characters 52-58. bad entrypoint format: entrypoint "Toto" is badly formatted. We expect "%bar" for entrypoint Bar and "%default" when no entrypoint used {"location":"in file \"self_bad_entrypoint_format.ligo\", line 8, characters 52-58"}
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}];
run_ligo_bad ["compile-contract"; bad_contract "nested_bigmap_1.religo"; "main"];
[%expect {|
ligo: It looks like you have nested a big map inside another big map. This is not supported. : {}
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}];
run_ligo_bad ["compile-contract"; bad_contract "nested_bigmap_2.religo"; "main"];
[%expect {|
ligo: It looks like you have nested a big map inside another big map. This is not supported. : {}
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}];
run_ligo_bad ["compile-contract"; bad_contract "nested_bigmap_3.religo"; "main"];
[%expect {|
ligo: It looks like you have nested a big map inside another big map. This is not supported. : {}
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog' |}];
run_ligo_bad ["compile-contract"; bad_contract "nested_bigmap_4.religo"; "main"];
[%expect {|
ligo: It looks like you have nested a big map inside another big map. This is not supported. : {}
If you're not sure how to fix this error, you can
do one of the following:
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
2020-03-16 21:34:43 +04:00
* Check the changelog by running 'ligo changelog' |}]