2019-11-21 14:06:34 -06:00
open Cli_expect
let contract basename =
" ../../test/contracts/ " ^ basename
2020-01-20 19:40:45 +01:00
let bad_contract basename =
" ../../test/contracts/negative/ " ^ basename
2019-11-21 14:06:34 -06:00
2019-11-25 17:30:12 -06:00
let % expect_test _ =
run_ligo_good [ " measure-contract " ; contract " coase.ligo " ; " main " ] ;
2020-02-03 17:34:52 -06:00
[ % expect { | 1700 bytes | } ] ;
2019-11-25 17:30:12 -06:00
run_ligo_good [ " measure-contract " ; contract " multisig.ligo " ; " main " ] ;
2020-02-03 17:34:52 -06:00
[ % expect { | 995 bytes | } ] ;
2019-11-25 17:30:12 -06:00
run_ligo_good [ " measure-contract " ; contract " multisig-v2.ligo " ; " main " ] ;
2020-02-03 17:34:52 -06:00
[ % expect { | 2512 bytes | } ] ;
2019-11-25 17:30:12 -06:00
run_ligo_good [ " measure-contract " ; contract " vote.mligo " ; " main " ] ;
2020-02-03 17:34:52 -06:00
[ % expect { | 582 bytes | } ] ;
2019-11-25 17:30:12 -06:00
2019-12-18 16:35:17 +01: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 10:54:21 +00:00
[ % expect { |
2020-04-10 03:10:12 +02:00
ligo : different kinds : { " a " : " record[card_patterns -> (type_operator: Map (nat,record[coefficient -> mutez , quantity -> nat])) , \n cards -> (type_operator: 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 10:54:21 +00:00
If you're not sure how to fix this error , you can
do one of the following :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-01-08 10:54:21 +00:00
* 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 16:35:17 +01: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 10:54:21 +00:00
[ % expect { |
2020-04-10 03:10:12 +02:00
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 -> (type_operator: Map (nat,record[coefficient -> mutez , quantity -> nat])) , \n cards -> (type_operator: Map (nat,record[card_owner -> address , card_pattern -> nat])) , \n next_id -> nat] " }
2020-01-08 10:54:21 +00:00
If you're not sure how to fix this error , you can
do one of the following :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-01-08 10:54:21 +00:00
* 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 16:35:17 +01:00
2019-11-25 17:30:12 -06:00
()
2020-01-03 18:09:16 +01: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-25 17:30:12 -06:00
let % expect_test _ =
2019-11-21 14:06:34 -06:00
run_ligo_good [ " compile-contract " ; contract " coase.ligo " ; " main " ] ;
[ % expect { |
2020-01-11 19:44:10 -06:00
{ 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 ) ) ;
code { DUP ;
CDR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
CAR ;
IF_LEFT
{ DUP ;
2019-11-25 17:15:25 -06:00
IF_LEFT
2020-02-03 17:33:47 -06:00
{ DIG 2 ;
DUP ;
DUG 3 ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2019-11-25 17:15:25 -06:00
PAIR ;
DUP ;
2019-11-21 14:06:34 -06:00
CAR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2019-11-21 14:06:34 -06:00
CDR ;
DUP ;
CAR ;
2020-01-11 19:44:10 -06:00
CAR ;
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
GET ;
IF_NONE
{ PUSH string " buy_single: No card pattern. " ; FAILWITH }
{ DUP ; DIP { DROP } } ;
PUSH nat 1 ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2019-11-21 14:06:34 -06:00
CDR ;
2020-01-11 19:44:10 -06:00
ADD ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
CAR ;
MUL ;
AMOUNT ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
COMPARE ;
GT ;
IF { PUSH string " Not enough money " ; FAILWITH } { PUSH unit Unit } ;
2019-11-21 14:06:34 -06:00
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
PUSH nat 1 ;
DIG 4 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 5 ;
2020-01-11 19:44:10 -06:00
CDR ;
ADD ;
SWAP ;
CAR ;
PAIR ;
DIG 4 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 5 ;
2020-01-11 19:44:10 -06:00
DIG 5 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 6 ;
2020-01-11 19:44:10 -06:00
CAR ;
2019-11-21 14:06:34 -06:00
CAR ;
2020-01-11 19:44:10 -06:00
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
DIG 8 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 9 ;
2020-01-11 19:44:10 -06:00
SWAP ;
SOME ;
SWAP ;
UPDATE ;
DIP { DUP ; CDR ; SWAP ; CAR ; CDR } ;
PAIR ;
PAIR ;
DUP ;
CAR ;
CDR ;
DIG 7 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 8 ;
2020-01-11 19:44:10 -06:00
SENDER ;
PAIR ;
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
CDR ;
SWAP ;
SOME ;
SWAP ;
UPDATE ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
DIP { DUP ; CDR ; SWAP ; CAR ; CAR } ;
SWAP ;
PAIR ;
PAIR ;
DUP ;
PUSH nat 1 ;
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
CDR ;
ADD ;
SWAP ;
CAR ;
PAIR ;
DUP ;
NIL operation ;
PAIR ;
DIP { DROP 12 } }
2020-02-03 17:33:47 -06:00
{ DIG 2 ;
DUP ;
DUG 3 ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
PAIR ;
DUP ;
CAR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
CDR ;
DUP ;
CAR ;
CDR ;
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2019-11-21 14:06:34 -06:00
GET ;
2020-02-27 19:09:14 +01:00
IF_NONE
2020-01-11 19:44:10 -06:00
{ PUSH string " sell_single: No card. " ; FAILWITH }
2020-02-27 19:09:14 +01:00
{ DUP ; DIP { DROP } } ;
2020-01-21 02:24:16 -06:00
SENDER ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
CAR ;
2019-11-21 14:06:34 -06:00
COMPARE ;
NEQ ;
IF { PUSH string " This card doesn't belong to you " ; FAILWITH }
{ PUSH unit Unit } ;
2020-01-11 19:44:10 -06:00
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
CAR ;
CAR ;
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
CDR ;
GET ;
IF_NONE
{ PUSH string " sell_single: No card pattern. " ; FAILWITH }
{ DUP ; DIP { DROP } } ;
DUP ;
PUSH nat 1 ;
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
CDR ;
SUB ;
ABS ;
SWAP ;
CAR ;
PAIR ;
DIG 4 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 5 ;
2019-12-04 18:30:52 +01:00
DIG 5 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 6 ;
2019-11-21 14:06:34 -06:00
CAR ;
2020-01-11 19:44:10 -06:00
CAR ;
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
DIG 6 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 7 ;
2020-01-11 19:44:10 -06:00
CDR ;
SWAP ;
SOME ;
SWAP ;
2019-11-21 14:06:34 -06:00
UPDATE ;
2020-01-11 19:44:10 -06:00
DIP { DUP ; CDR ; SWAP ; CAR ; CDR } ;
PAIR ;
PAIR ;
DUP ;
CAR ;
CDR ;
DIG 7 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 8 ;
2020-01-11 19:44:10 -06:00
NONE ( pair ( address % card_owner ) ( nat % card_pattern ) ) ;
SWAP ;
UPDATE ;
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
CDR ;
DIG 3 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 4 ;
2020-01-11 19:44:10 -06:00
CAR ;
MUL ;
SENDER ;
CONTRACT unit ;
IF_NONE
{ PUSH string " sell_single: No contract. " ; FAILWITH }
{ DUP ; DIP { DROP } } ;
DUP ;
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
UNIT ;
TRANSFER_TOKENS ;
NIL operation ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
CONS ;
DIG 5 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 6 ;
2020-01-11 19:44:10 -06:00
DIG 5 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 6 ;
2019-12-04 18:30:52 +01:00
DIP { DUP ; CDR ; SWAP ; CAR ; CAR } ;
2019-11-21 14:06:34 -06:00
SWAP ;
PAIR ;
PAIR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2019-11-21 14:06:34 -06:00
PAIR ;
2020-01-11 19:44:10 -06:00
DIP { DROP 14 } } ;
DIP { DROP } }
2020-02-03 17:34:52 -06:00
{ DIG 1 ;
DUP ;
DUG 2 ;
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
PAIR ;
DUP ;
CAR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
CDR ;
DUP ;
2019-11-25 17:15:25 -06:00
CAR ;
CDR ;
2020-01-11 19:44:10 -06:00
DUP ;
DIG 3 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 4 ;
2019-11-25 17:15:25 -06:00
CAR ;
2020-01-11 19:44:10 -06:00
GET ;
IF_NONE
{ PUSH string " transfer_single: No card. " ; FAILWITH }
{ DUP ; DIP { DROP } } ;
SENDER ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2019-11-25 17:15:25 -06:00
CAR ;
COMPARE ;
NEQ ;
2020-01-11 19:44:10 -06:00
IF { PUSH string " This card doesn't belong to you " ; FAILWITH }
{ PUSH unit Unit } ;
DIG 3 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 4 ;
2020-01-11 19:44:10 -06:00
DIG 3 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 4 ;
2020-01-11 19:44:10 -06:00
DIG 3 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 4 ;
2020-01-11 19:44:10 -06:00
DIG 7 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 8 ;
2020-01-11 19:44:10 -06:00
CDR ;
SWAP ;
CDR ;
SWAP ;
PAIR ;
DIG 7 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 8 ;
2020-01-11 19:44:10 -06:00
CAR ;
SWAP ;
SOME ;
SWAP ;
UPDATE ;
DIP { DUP ; CDR ; SWAP ; CAR ; CAR } ;
SWAP ;
PAIR ;
PAIR ;
NIL operation ;
PAIR ;
DIP { DROP 7 } } ;
DIP { DROP 2 } } } | } ]
2020-02-03 17:34:52 -06:00
let % expect_test _ =
run_ligo_good [ " compile-contract " ; contract " multisig.ligo " ; " main " ] ;
[ % expect { |
{ parameter
( pair ( pair ( nat % counter ) ( lambda % message unit ( list operation ) ) )
( list % signatures ( pair key_hash signature ) ) ) ;
storage
( pair ( pair ( list % auth key ) ( nat % counter ) ) ( pair ( string % id ) ( nat % threshold ) ) ) ;
code { DUP ;
CAR ;
DIG 1 ;
DUP ;
DUG 2 ;
CDR ;
DIG 1 ;
DUP ;
DUG 2 ;
CAR ;
CDR ;
DIG 1 ;
DUP ;
DUG 2 ;
CAR ;
CDR ;
DIG 3 ;
DUP ;
DUG 4 ;
CAR ;
CAR ;
COMPARE ;
NEQ ;
IF { PUSH string " Counters does not match " ; FAILWITH }
{ CHAIN_ID ;
DIG 2 ;
DUP ;
DUG 3 ;
CDR ;
CAR ;
PAIR ;
DIG 3 ;
DUP ;
DUG 4 ;
CAR ;
CAR ;
DIG 2 ;
DUP ;
DUG 3 ;
PAIR ;
PAIR ;
PACK ;
PUSH nat 0 ;
DIG 3 ;
DUP ;
DUG 4 ;
CAR ;
CAR ;
PAIR ;
DIG 4 ;
DUP ;
DUG 5 ;
CDR ;
ITER { SWAP ;
PAIR ;
DUP ;
CAR ;
CDR ;
DIG 1 ;
DUP ;
DUG 2 ;
CAR ;
CAR ;
DIG 2 ;
DUP ;
DUG 3 ;
CDR ;
DIG 2 ;
DUP ;
DUG 3 ;
DIG 2 ;
DUP ;
DUG 3 ;
PAIR ;
DIG 2 ;
DUP ;
DUG 3 ;
IF_CONS
{ DUP ;
HASH_KEY ;
DIG 4 ;
DUP ;
DUG 5 ;
CAR ;
COMPARE ;
EQ ;
IF { DIG 7 ;
DUP ;
DUG 8 ;
DIG 4 ;
DUP ;
DUG 5 ;
CDR ;
DIG 2 ;
DUP ;
DUG 3 ;
CHECK_SIGNATURE ;
IF { PUSH nat 1 ;
DIG 6 ;
DUP ;
DUG 7 ;
ADD ;
DIG 6 ;
DUP ;
DUG 7 ;
DIG 1 ;
DUP ;
DUG 2 ;
DIP { DROP 2 } }
{ PUSH string " Invalid signature " ; FAILWITH } ;
DIG 6 ;
DUP ;
DUG 7 ;
DIG 1 ;
DUP ;
DUG 2 ;
DIP { DROP 2 } }
{ DIG 5 ; DUP ; DUG 6 } ;
DIG 3 ;
DUP ;
DUG 4 ;
DIG 3 ;
DUP ;
DUG 4 ;
SWAP ;
CDR ;
SWAP ;
PAIR ;
DIG 1 ;
DUP ;
DUG 2 ;
SWAP ;
CAR ;
PAIR ;
DIP { DROP 3 } }
{ DUP } ;
DIG 5 ;
DUP ;
DUG 6 ;
DIG 1 ;
DUP ;
DUG 2 ;
CAR ;
DIP { DUP ; CDR ; SWAP ; CAR ; CDR } ;
PAIR ;
PAIR ;
DIG 1 ;
DUP ;
DUG 2 ;
CDR ;
DIP { DUP ; CDR ; SWAP ; CAR ; CAR } ;
SWAP ;
PAIR ;
PAIR ;
CAR ;
DIP { DROP 6 } } ;
DIG 3 ;
DUP ;
DUG 4 ;
CDR ;
CDR ;
DIG 1 ;
DUP ;
DUG 2 ;
CDR ;
COMPARE ;
LT ;
IF { PUSH string " Not enough signatures passed the check " ; FAILWITH }
{ DIG 3 ;
DUP ;
DUG 4 ;
PUSH nat 1 ;
DIG 5 ;
DUP ;
DUG 6 ;
CAR ;
CDR ;
ADD ;
DIP { DUP ; CDR ; SWAP ; CAR ; CAR } ;
SWAP ;
PAIR ;
PAIR ;
DIG 4 ;
DUP ;
DUG 5 ;
DIG 1 ;
DUP ;
DUG 2 ;
DIP { DROP 2 } } ;
DIG 4 ;
DUP ;
DUG 5 ;
DIG 1 ;
DUP ;
DUG 2 ;
DIP { DROP 4 } } ;
DUP ;
UNIT ;
DIG 3 ;
DUP ;
DUG 4 ;
SWAP ;
EXEC ;
PAIR ;
DIP { DROP 5 } } } | } ]
2019-11-25 17:30:12 -06:00
let % expect_test _ =
run_ligo_good [ " compile-contract " ; contract " multisig-v2.ligo " ; " main " ] ;
[ % expect { |
2020-02-03 17:33:47 -06:00
{ parameter
( or ( or ( unit % default ) ( lambda % send bytes ( list operation ) ) )
( lambda % withdraw bytes ( list operation ) ) ) ;
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 ) ) ) ;
code { DUP ;
CDR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
CAR ;
IF_LEFT
{ DUP ;
2019-11-29 10:00:54 -06:00
IF_LEFT
2020-02-03 17:33:47 -06:00
{ DIG 2 ; DUP ; DUG 3 ; NIL operation ; PAIR ; DIP { DROP } }
{ DIG 2 ;
DUP ;
DUG 3 ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
PAIR ;
DUP ;
CDR ;
DUP ;
CAR ;
CAR ;
CAR ;
SENDER ;
MEM ;
NOT ;
IF { PUSH string " Unauthorized address " ; FAILWITH } { PUSH unit Unit } ;
DIG 2 ;
DUP ;
DUG 3 ;
CAR ;
DUP ;
PACK ;
DIG 3 ;
DUP ;
DUG 4 ;
CAR ;
CAR ;
CDR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
SIZE ;
COMPARE ;
GT ;
IF { PUSH string " Message size exceed maximum limit " ; FAILWITH }
{ PUSH unit Unit } ;
EMPTY_SET address ;
DIG 5 ;
DUP ;
DUG 6 ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
PAIR ;
DIG 6 ;
DUP ;
DUG 7 ;
CAR ;
CDR ;
CDR ;
DIG 4 ;
DUP ;
DUG 5 ;
GET ;
IF_NONE
{ DIG 6 ;
2019-11-29 10:00:54 -06:00
DUP ;
2020-02-03 17:33:47 -06:00
DUG 7 ;
DIG 7 ;
2019-11-29 10:00:54 -06:00
DUP ;
2020-02-03 17:33:47 -06:00
DUG 8 ;
2020-01-11 19:44:10 -06:00
CDR ;
CAR ;
2019-12-04 18:30:52 +01:00
CAR ;
2020-02-03 17:33:47 -06:00
PUSH nat 1 ;
DIG 9 ;
2019-12-04 18:30:52 +01:00
DUP ;
2020-02-03 17:33:47 -06:00
DUG 10 ;
2019-11-29 10:00:54 -06:00
CDR ;
CAR ;
CAR ;
SENDER ;
GET ;
2020-02-06 18:06:36 +01:00
IF_NONE { PUSH string " MAP FIND " ; FAILWITH } { } ;
2020-02-03 17:33:47 -06:00
ADD ;
SOME ;
SENDER ;
UPDATE ;
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
PAIR ;
PAIR ;
SWAP ;
PAIR ;
EMPTY_SET address ;
PUSH bool True ;
SENDER ;
UPDATE ;
DIG 2 ;
DUP ;
DUG 3 ;
DIG 2 ;
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
SWAP ;
CAR ;
2020-02-03 17:33:47 -06:00
PAIR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
SWAP ;
2020-01-11 19:44:10 -06:00
CDR ;
SWAP ;
2020-03-16 18:34:43 +01:00
PAIR ;
2020-02-03 17:33:47 -06:00
DIP { DROP 2 } }
{ DUP ;
SENDER ;
MEM ;
IF { DIG 7 ; DUP ; DUG 8 }
{ DIG 7 ;
2019-12-04 18:30:52 +01:00
DUP ;
2020-02-03 17:33:47 -06:00
DUG 8 ;
DIG 8 ;
2019-12-04 18:30:52 +01:00
DUP ;
2020-02-03 17:33:47 -06:00
DUG 9 ;
2019-11-29 10:00:54 -06:00
CDR ;
CAR ;
CAR ;
2020-02-03 17:33:47 -06:00
PUSH nat 1 ;
DIG 10 ;
DUP ;
DUG 11 ;
2020-03-27 14:57:56 +01:00
CDR ;
2019-12-04 18:30:52 +01:00
CAR ;
2020-01-11 19:44:10 -06:00
CAR ;
2020-02-03 17:33:47 -06:00
SENDER ;
GET ;
IF_NONE { PUSH string " MAP FIND " ; FAILWITH } { } ;
ADD ;
2020-01-11 19:44:10 -06:00
SOME ;
2020-02-03 17:33:47 -06:00
SENDER ;
2019-11-29 10:00:54 -06:00
UPDATE ;
2020-02-03 17:33:47 -06:00
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
2019-11-29 10:00:54 -06:00
PAIR ;
PAIR ;
2020-02-03 17:33:47 -06:00
SWAP ;
2019-11-29 10:00:54 -06:00
PAIR ;
2020-02-03 17:33:47 -06:00
DIG 8 ;
DUP ;
DUG 9 ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
DIP { DROP 2 } } ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
PUSH bool True ;
SENDER ;
UPDATE ;
DIG 3 ;
2019-11-29 10:00:54 -06:00
DUP ;
2020-02-03 17:33:47 -06:00
DUG 4 ;
DIG 2 ;
DUP ;
DUG 3 ;
SWAP ;
CAR ;
PAIR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
SWAP ;
2020-02-03 17:33:47 -06:00
CDR ;
SWAP ;
PAIR ;
DIP { DROP 3 } } ;
DUP ;
CAR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
CDR ;
2019-11-29 10:00:54 -06:00
DUP ;
CDR ;
CAR ;
2020-02-03 17:33:47 -06:00
CAR ;
SENDER ;
GET ;
IF_NONE { PUSH string " MAP FIND " ; FAILWITH } { } ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
CAR ;
CDR ;
2020-02-03 17:33:47 -06:00
CAR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
COMPARE ;
GT ;
IF { PUSH string " Maximum number of proposal reached " ; FAILWITH }
{ PUSH unit Unit } ;
2019-11-29 10:00:54 -06:00
NIL operation ;
2020-02-03 17:33:47 -06:00
DIG 3 ;
DUP ;
DUG 4 ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2019-11-29 10:00:54 -06:00
PAIR ;
2020-02-03 17:33:47 -06:00
DIG 4 ;
DUP ;
DUG 5 ;
CDR ;
CDR ;
DIG 6 ;
DUP ;
DUG 7 ;
SIZE ;
COMPARE ;
GE ;
IF { DIG 4 ;
DUP ;
DUG 5 ;
DIG 5 ;
DUP ;
DUG 6 ;
CAR ;
CDR ;
CDR ;
DIG 12 ;
DUP ;
DUG 13 ;
NONE ( set address ) ;
SWAP ;
UPDATE ;
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; CAR } ;
SWAP ;
PAIR ;
SWAP ;
PAIR ;
PAIR ;
DUP ;
CDR ;
CAR ;
CDR ;
DIG 13 ;
DUP ;
DUG 14 ;
SWAP ;
EXEC ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
DIG 13 ;
DUP ;
DUG 14 ;
DIG 3 ;
DUP ;
DUG 4 ;
CDR ;
CAR ;
CDR ;
CONCAT ;
SHA256 ;
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CAR } ;
SWAP ;
PAIR ;
PAIR ;
SWAP ;
PAIR ;
DUP ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
CDR ;
CAR ;
CAR ;
ITER { SWAP ;
PAIR ;
DUP ;
CAR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
CDR ;
CAR ;
DIG 11 ;
DUP ;
DUG 12 ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
MEM ;
2020-02-03 17:34:52 -06:00
IF { DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
DIG 2 ;
DUP ;
DUG 3 ;
CDR ;
CAR ;
CAR ;
PUSH nat 1 ;
DIG 5 ;
DUP ;
DUG 6 ;
CDR ;
CDR ;
SUB ;
ABS ;
DIG 3 ;
DUP ;
DUG 4 ;
SWAP ;
SOME ;
SWAP ;
UPDATE ;
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
PAIR ;
PAIR ;
SWAP ;
PAIR ;
DIG 2 ;
DUP ;
DUG 3 ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
DIP { DROP 2 } }
2020-02-03 17:34:52 -06:00
{ DIG 1 ; DUP ; DUG 2 } ;
2020-02-03 17:33:47 -06:00
DIG 3 ;
DUP ;
DUG 4 ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
SWAP ;
2020-02-03 17:33:47 -06:00
CDR ;
SWAP ;
PAIR ;
CAR ;
DIP { DROP 4 } } ;
DIG 4 ;
DUP ;
DUG 5 ;
DIG 4 ;
DUP ;
DUG 5 ;
SWAP ;
CAR ;
PAIR ;
DIG 3 ;
DUP ;
DUG 4 ;
SWAP ;
CDR ;
SWAP ;
PAIR ;
DIG 2 ;
DUP ;
DUG 3 ;
SWAP ;
CAR ;
PAIR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
SWAP ;
2020-02-03 17:33:47 -06:00
CAR ;
PAIR ;
DIP { DROP 4 } }
{ DUP ;
DIG 5 ;
DUP ;
DUG 6 ;
DIG 6 ;
DUP ;
DUG 7 ;
CAR ;
CDR ;
CDR ;
DIG 8 ;
DUP ;
DUG 9 ;
DIG 14 ;
DUP ;
DUG 15 ;
SWAP ;
SOME ;
SWAP ;
UPDATE ;
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; CAR } ;
SWAP ;
PAIR ;
SWAP ;
PAIR ;
PAIR ;
SWAP ;
CAR ;
PAIR } ;
DUP ;
DIP { DROP 17 } } ;
DIP { DROP } }
2020-02-03 17:34:52 -06:00
{ DIG 1 ;
DUP ;
DUG 2 ;
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
PAIR ;
DUP ;
CDR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
CAR ;
PACK ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
CAR ;
CDR ;
CDR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
GET ;
IF_NONE
2020-02-03 17:34:52 -06:00
{ DIG 1 ; DUP ; DUG 2 }
2020-02-03 17:33:47 -06:00
{ DUP ;
PUSH bool False ;
SENDER ;
UPDATE ;
DUP ;
SIZE ;
DIG 2 ;
DUP ;
DUG 3 ;
SIZE ;
COMPARE ;
NEQ ;
IF { DIG 3 ;
DUP ;
DUG 4 ;
DIG 4 ;
DUP ;
DUG 5 ;
CDR ;
CAR ;
CAR ;
PUSH nat 1 ;
DIG 6 ;
DUP ;
DUG 7 ;
CDR ;
CAR ;
CAR ;
SENDER ;
GET ;
IF_NONE { PUSH string " MAP FIND " ; FAILWITH } { } ;
SUB ;
ABS ;
SOME ;
SENDER ;
UPDATE ;
DIP { DUP ; CAR ; SWAP ; CDR ; DUP ; CDR ; SWAP ; CAR ; CDR } ;
PAIR ;
PAIR ;
SWAP ;
PAIR ;
DIG 4 ;
DUP ;
DUG 5 ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
DIP { DROP 2 } }
{ DIG 3 ; DUP ; DUG 4 } ;
PUSH nat 0 ;
DIG 2 ;
DUP ;
DUG 3 ;
SIZE ;
COMPARE ;
EQ ;
IF { DUP ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
CAR ;
CDR ;
CDR ;
DIG 5 ;
DUP ;
DUG 6 ;
NONE ( set address ) ;
SWAP ;
UPDATE ;
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; CAR } ;
SWAP ;
PAIR ;
SWAP ;
PAIR ;
PAIR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
DIP { DROP 2 } }
{ DUP ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-02-03 17:33:47 -06:00
DIG 2 ;
DUP ;
DUG 3 ;
CAR ;
CDR ;
CDR ;
DIG 4 ;
DUP ;
DUG 5 ;
DIG 7 ;
DUP ;
DUG 8 ;
SWAP ;
SOME ;
SWAP ;
UPDATE ;
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CAR ; SWAP ; CDR ; CAR } ;
SWAP ;
PAIR ;
SWAP ;
PAIR ;
PAIR ;
DIP { DROP } } ;
DIG 5 ;
DUP ;
DUG 6 ;
DIG 2 ;
DUP ;
DUG 3 ;
2020-02-03 17:34:52 -06:00
DIP { DROP } ;
DIG 1 ;
DUP ;
DUG 2 ;
2020-04-08 19:11:18 -05:00
DIP { DROP 5 } } ;
2020-02-03 17:33:47 -06:00
DUP ;
NIL operation ;
PAIR ;
DIP { DROP 5 } } ;
DIP { DROP 2 } } } | } ]
2019-11-25 17:30:12 -06:00
let % expect_test _ =
run_ligo_good [ " compile-contract " ; contract " vote.mligo " ; " main " ] ;
[ % expect { |
2020-01-11 19:44:10 -06:00
{ parameter
( or ( pair % reset ( pair ( timestamp % finish_time ) ( timestamp % start_time ) ) ( string % title ) )
( or % vote ( unit % nay ) ( unit % yea ) ) ) ;
storage
( pair ( pair ( pair ( timestamp % finish_time ) ( nat % nay ) )
( pair ( timestamp % start_time ) ( string % title ) ) )
( pair ( set % voters address ) ( nat % yea ) ) ) ;
code { DUP ;
CAR ;
IF_LEFT
{ PUSH nat 0 ;
EMPTY_SET address ;
PAIR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
CDR ;
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
CAR ;
CDR ;
PAIR ;
PUSH nat 0 ;
DIG 3 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 4 ;
2020-01-11 19:44:10 -06:00
CAR ;
CAR ;
PAIR ;
PAIR ;
PAIR ;
NIL operation ;
PAIR ;
DIP { DROP } }
2020-02-03 17:34:52 -06:00
{ DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
CDR ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
PAIR ;
DUP ;
CDR ;
NOW ;
SENDER ;
DIG 3 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 4 ;
2019-11-25 17:15:25 -06:00
CAR ;
IF_LEFT
2020-02-03 17:33:47 -06:00
{ DIG 3 ;
DUP ;
DUG 4 ;
2020-01-11 19:44:10 -06:00
PUSH nat 1 ;
DIG 5 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 6 ;
2019-11-25 18:10:49 -06:00
CAR ;
CAR ;
2020-01-11 19:44:10 -06:00
CDR ;
ADD ;
DIP { DUP ; CDR ; SWAP ; CAR ; DUP ; CDR ; SWAP ; CAR ; CAR } ;
2020-03-02 18:01:56 +01:00
SWAP ;
2019-11-25 17:30:12 -06:00
PAIR ;
PAIR ;
PAIR ;
2020-04-08 19:11:18 -05:00
DIP { DROP } }
2020-02-03 17:33:47 -06:00
{ DIG 3 ;
DUP ;
DUG 4 ;
2020-01-11 19:44:10 -06:00
PUSH nat 1 ;
DIG 5 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 6 ;
2020-01-11 19:44:10 -06:00
CDR ;
CDR ;
ADD ;
DIP { DUP ; CAR ; SWAP ; CDR ; CAR } ;
2020-03-02 18:01:56 +01:00
SWAP ;
2019-11-25 17:30:12 -06:00
PAIR ;
2020-01-11 19:44:10 -06:00
SWAP ;
2019-11-25 17:30:12 -06:00
PAIR ;
2020-01-11 19:44:10 -06:00
DIP { DROP } } ;
DUP ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
CDR ;
CAR ;
DIG 3 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 4 ;
2020-01-11 19:44:10 -06:00
PUSH bool True ;
SWAP ;
UPDATE ;
DIP { DUP ; CAR ; SWAP ; CDR ; CDR } ;
PAIR ;
SWAP ;
PAIR ;
NIL operation ;
PAIR ;
DIP { DROP 6 } } ;
DIP { DROP } } } | } ]
2019-12-16 12:10:31 -08:00
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 12:20:39 +01:00
2020-01-21 00:35:58 -06:00
let % expect_test _ =
run_ligo_good [ " compile-contract " ; contract " amount_lambda.mligo " ; " main " ] ;
(* AMOUNT should occur inside the second lambda, but not the first lambda *)
[ % expect { |
{ parameter bool ;
storage ( lambda unit mutez ) ;
code { DUP ;
CAR ;
IF { AMOUNT ;
DUP ;
LAMBDA
( pair mutez unit )
mutez
2020-02-03 17:34:52 -06:00
{ DUP ; CAR ; SWAP ; CDR ; DIG 1 ; DUP ; DUG 2 ; DIP { DROP 2 } } ;
2020-01-21 00:35:58 -06:00
SWAP ;
APPLY ;
DIP { DROP } }
{ LAMBDA unit mutez { DROP ; AMOUNT } } ;
NIL operation ;
PAIR ;
DIP { DROP } } } | } ]
2020-04-09 16:24:55 +02:00
let % expect_test _ =
run_ligo_good [ " print-ast-typed " ; contract " sequence.mligo " ; ] ;
[ % expect { | const y = lambda ( _ ) return let x = + 1 in let _ = let x = + 2 in UNIT () in let _ = let x = + 23 in UNIT () in let _ = let x = + 42 in UNIT () in x | } ]
2019-12-24 12:20:39 +01:00
let % expect_test _ =
run_ligo_bad [ " compile-contract " ; contract " bad_type_operator.ligo " ; " main " ] ;
2020-01-08 10:54:21 +00: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 :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-01-08 10:54:21 +00:00
* 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-31 15:27:06 +01:00
2020-01-02 15:02:02 +01:00
let % expect_test _ =
run_ligo_bad [ " compile-contract " ; contract " bad_address_format.religo " ; " main " ] ;
2020-01-08 10:54:21 +00:00
[ % expect { |
2020-03-02 18:01:56 +01: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 10:54:21 +00:00
If you're not sure how to fix this error , you can
do one of the following :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-01-08 10:54:21 +00:00
* 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 17:46:31 +01:00
let % expect_test _ =
run_ligo_bad [ " compile-contract " ; contract " bad_timestamp.ligo " ; " main " ] ;
2020-01-08 10:54:21 +00:00
[ % expect { |
2020-02-10 19:33:04 +01:00
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 10:54:21 +00:00
If you're not sure how to fix this error , you can
do one of the following :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-01-08 10:54:21 +00:00
* 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 18:51:43 +01:00
let % expect_test _ =
run_ligo_good [ " dry-run " ; contract " redeclaration.ligo " ; " main " ; " unit " ; " 0 " ] ;
2020-03-16 18:34:43 +01:00
[ % expect { | ( LIST_EMPTY () , 0 ) | } ]
2020-01-06 18:51:43 +01:00
let % expect_test _ =
run_ligo_good [ " dry-run " ; contract " double_main.ligo " ; " main " ; " unit " ; " 0 " ] ;
2020-03-16 18:34:43 +01:00
[ % expect { | ( LIST_EMPTY () , 2 ) | } ]
2020-01-06 14:19:14 -06: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 16:35:53 +01:00
run_ligo_good [ " dry-run " ; contract " subtle_nontail_fail.mligo " ; " main " ; " () " ; " () " ] ;
2020-01-06 14:19:14 -06:00
[ % expect { |
2020-01-17 17:02:54 +01:00
failwith ( " This contract always fails " ) | } ]
2020-01-06 14:19:14 -06:00
2020-01-20 19:40:45 +01: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 :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-01-20 19:40:45 +01:00
* Ask a question on our Discord : https : // discord . gg / 9rhYaEt
* Open a gitlab issue : https : // gitlab . com / ligolang / ligo / issues / new
2020-01-27 11:42:32 +01: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 { |
2020-02-07 16:33:09 +01:00
( Pair { Elt 23 0 ; Elt 42 0 } Unit ) | } ]
2020-02-13 16:44:21 +01:00
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 ) ) ;
2020-02-19 16:10:50 +01:00
code { DUP ; CDR ; NIL operation ; PAIR ; DIP { DROP } } } | } ]
2020-02-21 17:08:10 +01:00
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 :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-02-21 17:08:10 +01:00
* 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-19 16:10:50 +01:00
let % expect_test _ =
run_ligo_good [ " dry-run " ; contract " super-counter.mligo " ; " main " ; " test_param " ; " test_storage " ] ;
[ % expect { |
2020-03-16 18:34:43 +01:00
( LIST_EMPTY () , 3 ) | } ]
2020-02-26 18:54:16 +01:00
let % expect_test _ =
run_ligo_bad [ " compile-contract " ; bad_contract " redundant_constructors.mligo " ; " main " ] ;
[ % expect { |
2020-04-22 17:56:27 +02:00
ligo : redundant constructor : { " constructor " : " Add " , " environment " : " - E[] \t T[union_a -> sum[Add -> int , Remove -> int]] \n - E[] \t T[bool -> sum[false -> unit , true -> unit]]] " }
2020-02-26 18:54:16 +01:00
If you're not sure how to fix this error , you can
do one of the following :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-02-26 18:54:16 +01:00
* Ask a question on our Discord : https : // discord . gg / 9rhYaEt
* Open a gitlab issue : https : // gitlab . com / ligolang / ligo / issues / new
2020-02-28 19:49:51 +01:00
* Check the changelog by running ' ligo changelog' | } ]
let % expect_test _ =
run_ligo_bad [ " compile-contract " ; bad_contract " create_contract_toplevel.mligo " ; " main " ] ;
[ % expect { |
2020-04-21 16:39:51 +02:00
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#2 = #P in \n let p = rhs#2.0 in \n let s = rhs#2.1 in \n ( LIST_EMPTY() : (type_operator: list(operation)) , store ) , \n NONE() : (type_operator: 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 19:49:51 +01:00
2020-03-04 15:59:47 +01:00
If you're not sure how to fix this error , you can
do one of the following :
2020-02-28 19:49:51 +01:00
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-03-04 15:59:47 +01:00
* 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 19:49:51 +01:00
run_ligo_bad [ " compile-contract " ; bad_contract " create_contract_var.mligo " ; " main " ] ;
[ % expect { |
2020-04-21 16:39:51 +02:00
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#2 = #P in \n let p = rhs#2.0 in \n let s = rhs#2.1 in \n ( LIST_EMPTY() : (type_operator: list(operation)) , a ) , \n NONE() : (type_operator: 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 19:49:51 +01:00
2020-03-04 15:59:47 +01:00
If you're not sure how to fix this error , you can
do one of the following :
2020-02-28 19:49:51 +01:00
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-03-04 15:59:47 +01:00
* 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 12:53:10 +01:00
run_ligo_bad [ " compile-contract " ; bad_contract " create_contract_no_inline.mligo " ; " main " ] ;
[ % expect { |
2020-04-22 17:56:27 +02:00
ligo : in file " create_contract_no_inline.mligo " , line 3 , characters 40 - 46 . unbound type variable : { " variable " : " return " , " location " : " in file \" create_contract_no_inline.mligo \" , line 3, characters 40-46 " , " in " : " - E[foo -> int] \t T[] - E[] \t T[bool -> sum[false -> unit , true -> unit]]] " , " did_you_mean " : " no suggestion " }
2020-03-02 12:53:10 +01:00
If you're not sure how to fix this error , you can
do one of the following :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-03-02 12:53:10 +01:00
* 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 19:49:51 +01: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 ;
2020-02-03 17:34:52 -06:00
DIG 1 ;
DUP ;
DUG 2 ;
2020-01-11 19:44:10 -06:00
CDR ;
NIL operation ;
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
CAR ;
2020-02-28 19:49:51 +01:00
CONS ;
PAIR ;
2020-04-13 10:31:09 +02:00
DIP { DROP 2 } } } | } ] ;
run_ligo_good [ " compile-contract " ; contract " tuples_no_annotation.religo " ; " main " ] ;
[ % expect { |
{ parameter int ;
storage ( pair ( pair int string ) ( pair nat bool ) ) ;
2020-01-11 19:44:10 -06:00
code { PUSH bool False ;
PUSH nat 2 ;
PAIR ;
PUSH string " 2 " ;
2020-04-13 10:31:09 +02:00
PUSH int 2 ;
PAIR ;
PAIR ;
NIL operation ;
PAIR ;
DIP { DROP } } } | } ]
2020-03-04 15:38:10 +01:00
let % expect_test _ =
run_ligo_bad [ " compile-contract " ; bad_contract " self_type_annotation.ligo " ; " main " ] ;
[ % expect { |
2020-04-10 03:10:12 +02:00
ligo : in file " self_type_annotation.ligo " , line 8 , characters 41 - 64 . bad self type : expected ( type_operator : Contract ( int ) ) but got ( type_operator : Contract ( nat ) ) { " location " : " in file \" self_type_annotation.ligo \" , line 8, characters 41-64 " }
2020-03-04 15:38:10 +01:00
If you're not sure how to fix this error , you can
do one of the following :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-03-04 15:38:10 +01:00
* 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 ;
2020-02-03 17:34:52 -06:00
code { SELF % default ;
DIG 1 ;
DUP ;
DUG 2 ;
2020-03-06 18:25:28 +01:00
CDR ;
NIL operation ;
PAIR ;
DIP { DROP 2 } } } | } ]
2020-03-04 15:38:10 +01:00
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 :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-03-04 15:38:10 +01:00
* 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 { |
2020-04-10 03:10:12 +02:00
ligo : in file " " , line 0 , characters 0 - 0 . bad return type : expected ( type_operator : list ( operation ) ) , got string { " location " : " in file \" \" , line 0, characters 0-0 " , " entrypoint " : " main " }
2020-03-04 15:38:10 +01:00
If you're not sure how to fix this error , you can
do one of the following :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-03-04 15:38:10 +01:00
* 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 { |
2020-04-10 03:10:12 +02:00
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 ) -> ( (type_operator: list(operation)) * string ) " }
2020-03-04 15:38:10 +01:00
2020-03-06 18:25:28 +01:00
If you're not sure how to fix this error , you can
do one of the following :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-03-06 18:25:28 +01:00
* 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 ;
2020-01-11 19:44:10 -06:00
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
CDR ;
2020-03-06 18:25:28 +01:00
NIL operation ;
2020-01-11 19:44:10 -06:00
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-03-06 18:25:28 +01:00
CONS ;
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 ;
2020-01-11 19:44:10 -06:00
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-01-11 19:44:10 -06:00
CDR ;
2020-03-06 18:25:28 +01:00
NIL operation ;
2020-01-11 19:44:10 -06:00
DIG 2 ;
2020-02-03 17:33:47 -06:00
DUP ;
DUG 3 ;
2020-03-06 18:25:28 +01:00
CONS ;
PAIR ;
DIP { DROP 3 } } } | } ] ;
run_ligo_bad [ " compile-contract " ; bad_contract " self_bad_entrypoint_format.ligo " ; " main " ] ;
[ % expect { |
2020-03-09 11:22:56 +01:00
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 " }
2020-03-06 18:25:28 +01:00
2020-03-04 15:38:10 +01:00
If you're not sure how to fix this error , you can
do one of the following :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-03-04 15:38:10 +01:00
* Ask a question on our Discord : https : // discord . gg / 9rhYaEt
* Open a gitlab issue : https : // gitlab . com / ligolang / ligo / issues / new
2020-03-24 13:58:18 +01:00
* 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 :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-03-24 13:58:18 +01:00
* 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 :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-03-24 13:58:18 +01:00
* 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 :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-03-24 13:58:18 +01:00
* 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 :
2020-04-15 15:44:30 +02:00
* Visit our documentation : https : // ligolang . org / docs / intro / introduction
2020-03-24 13:58:18 +01:00
* Ask a question on our Discord : https : // discord . gg / 9rhYaEt
* Open a gitlab issue : https : // gitlab . com / ligolang / ligo / issues / new
2020-03-16 18:34:43 +01:00
* Check the changelog by running ' ligo changelog' | } ]