Michelson: some new contracts/tests
This commit is contained in:
parent
303c43b742
commit
f05b02f74f
@ -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 } } }
|
16
src/proto_alpha/lib_protocol/test/contracts/cps_fact.tz
Normal file
16
src/proto_alpha/lib_protocol/test/contracts/cps_fact.tz
Normal 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 } } }
|
14
src/proto_alpha/lib_protocol/test/contracts/cps_fact_2.tz
Normal file
14
src/proto_alpha/lib_protocol/test/contracts/cps_fact_2.tz
Normal 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 } } }
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user