Michelson: updates test suite to use int and nat

This commit is contained in:
Milo Davis 2017-07-18 17:38:20 +02:00 committed by Benjamin Canou
parent 98c96be749
commit 69736ec55b
8 changed files with 25 additions and 24 deletions

View File

@ -1,7 +1,7 @@
parameter uint64;
return (list uint64);
parameter nat;
return (list nat);
storage unit;
code {CAR; NIL uint64; SWAP; DUP; PUSH uint64 0; CMPNEQ;
LOOP {DUP; DIP {SWAP}; CONS; SWAP; PUSH uint64 1; SWAP; SUB;
DUP; PUSH uint64 0; CMPNEQ};
code {CAR; NIL nat; SWAP; DUP; PUSH nat 0; CMPNEQ;
LOOP {DUP; DIP {SWAP}; CONS; SWAP; PUSH nat 1; SWAP; SUB;
DUP; DIP{ABS} ; PUSH int 0; CMPNEQ};
CONS; UNIT; SWAP; PAIR};

View File

@ -1,8 +1,7 @@
parameter unit
code
{ # This contract stop to accept transactions after N incoming transactions
CDR ; PUSH uint32 1 ; SWAP ; SUB ;
DUP ; PUSH uint32 0 ; COMPARE ; EQ ; IF { FAIL } {} ;
UNIT ; PAIR }
{ # This contract stops accepting transactions after N incoming transactions
CDR ; DUP ; PUSH int 0 ; CMPLT; IF {PUSH int -1 ; ADD} {FAIL};
UNIT; PAIR}
return unit
storage uint32
storage int

View File

@ -1,10 +1,10 @@
parameter (list int32);
parameter (list int);
storage unit;
return (option int32);
code {CAR; DIP{NONE int32};
return (option int);
code {CAR; DIP{NONE int};
LAMBDA
(pair int32 (option int32))
(option int32)
(pair int (option int))
(option int)
{DUP; DUP; CAR; SWAP; CDR;
IF_NONE {DIP{DROP}; SOME} {CMPGT; IF {CDR} {CAR; SOME}}};
REDUCE; UNIT; SWAP; PAIR};

View File

@ -1,8 +1,8 @@
storage unit ;
parameter uint16 ;
parameter nat ;
return (list (contract unit unit)) ;
code
{ CAR ; DUP ; PUSH uint16 0 ; CMPNEQ ;
{ CAR ; DUP ; PUSH nat 0 ; CMPNEQ ;
DIIP { NIL (contract unit unit) } ;
LOOP
{ PUSH tez "5.00" ;
@ -11,7 +11,7 @@ code
PUSH key "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" ; # manager
CREATE_ACCOUNT ;
SWAP ; DIP { CONS } ;
PUSH uint16 1 ; SWAP ; SUB ;
DUP ; PUSH uint16 0 ; CMPNEQ } ;
PUSH nat 1 ; SWAP ; SUB ;
DUP ; PUSH nat 0 ; CMPNEQ } ;
DROP ;
UNIT ; SWAP ; PAIR }

View File

@ -1,4 +1,4 @@
parameter unit;
code {CAR; PUSH uint32 300; PAIR};
return uint32;
code {CAR; PUSH nat 300; PAIR};
return nat;
storage unit;

View File

@ -1,4 +1,4 @@
parameter unit;
return uint32;
return nat;
storage unit;
code {DROP; UNIT; STEPS_TO_QUOTA; PAIR};

View File

@ -1,7 +1,7 @@
# (pair signed_weather_data actual_level)
parameter (pair signature uint16);
parameter (pair signature nat);
# (pair (under_key over_key) (pair weather_service_key (pair rain_level days_in_future)))
storage (pair (pair (contract unit unit) (contract unit unit)) (pair uint16 key));
storage (pair (pair (contract unit unit) (contract unit unit)) (pair nat key));
return unit;
code {DUP; DUP;
CAR; DUP; DIP{CDR; H}; CAR; PAIR;

View File

@ -43,6 +43,7 @@ assert_output () {
local input=$2;
local storage=$3;
local expected=$4;
echo "Testing [$contract]"
local output=$(run_contract_file "$contract" "$input" "$storage" | sed '1,/output/d' |
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' ||
{ printf '\nTest failed with error at line %s\n' "$(caller)" > /dev/stderr;
@ -82,6 +83,7 @@ init_with_transfer () {
local INITIAL_STORAGE="$3"
local TRANSFER_AMT="$4"
local TRANSFER_SRC=${5-bootstrap1}
echo "Originating [$NAME]"
${TZCLIENT} originate contract ${NAME} \
for ${KEY} transferring "${TRANSFER_AMT}" \
from ${TRANSFER_SRC} running "${FILE}" -init "${INITIAL_STORAGE}"