Michelson: some new contracts/tests

This commit is contained in:
Benjamin Canou 2018-04-12 21:11:33 +02:00 committed by Grégoire Henry
parent 303c43b742
commit f05b02f74f
4 changed files with 34 additions and 1 deletions

View File

@ -11,6 +11,6 @@ code { UNPAIR ;
IF_NONE
{ NIL operation ; PAIR }
{ DUP ; DIP { PUSH nat 1 ; ADD ; MUL @storage } ; SWAP;
DIP { DIP { PUSH nat 4000 ; SELF; PUSH tez "0" } ;
DIP { DIP { SELF; PUSH tez "0" } ;
TRANSFER_TOKENS ; NIL operation ; SWAP ; CONS } ;
SWAP ; PAIR } } }

View File

@ -0,0 +1,16 @@
storage nat ;
parameter nat ;
code { UNPAIR ;
DIP { SELF ; ADDRESS ; SOURCE;
IFCMPEQ {} { DROP ; PUSH @storage nat 1 } };
DUP ;
PUSH nat 1 ;
IFCMPGE
{ DROP ; NIL operation ; PAIR }
{ PUSH nat 1 ; SWAP ; SUB @parameter ; ISNAT ;
IF_NONE
{ NIL operation ; PAIR }
{ DUP ; DIP { PUSH nat 1 ; ADD ; MUL @storage } ; SWAP;
DIP { DIP { SELF; PUSH tez "0" } ;
TRANSFER_TOKENS ; NIL operation ; SWAP ; CONS } ;
SWAP ; PAIR } } }

View File

@ -0,0 +1,14 @@
storage unit ;
parameter (pair nat nat) ;
code { CAR ; UNPAIR ;
DUP ;
PUSH nat 1 ;
IFCMPGE
{ DROP ; DROP ; UNIT ; NIL operation ; PAIR }
{ PUSH nat 1 ; SWAP ; SUB @parameter ; ISNAT ;
IF_NONE
{ DROP ; UNIT ; NIL operation ; PAIR }
{ DUP ; DIP { PUSH nat 1 ; ADD ; MUL @storage } ; PAIR ;
DIP { SELF; PUSH tez "0" } ;
TRANSFER_TOKENS ; NIL operation ; SWAP ; CONS ;
UNIT ; SWAP ; PAIR } } }

View File

@ -422,6 +422,9 @@ let test_example () =
test_output ~location: __LOC__ "diff_timestamps" "111" "(Pair 1 0)" "1" >>=? fun _ ->
test_output ~location: __LOC__ "diff_timestamps" "111" "(Pair \"1970-01-01T00:03:20Z\" \"1970-01-01T00:00:00Z\")" "200" >>=? fun _ ->
(* Test internal operations *)
test_output ~location: __LOC__ "cps_fact" "0" "4" "24" >>=? fun _ ->
(* Test NOW *)
let now = sb.tezos_header.shell.timestamp in
let now_str = quote @@ Tezos_base.Time.to_notation now in