From 69736ec55bc762e82177f1963c307fad2e2ca036 Mon Sep 17 00:00:00 2001 From: Milo Davis Date: Tue, 18 Jul 2017 17:38:20 +0200 Subject: [PATCH] Michelson: updates test suite to use `int` and `nat` --- test/contracts/build_list.tz | 10 +++++----- test/contracts/hardlimit.tz | 9 ++++----- test/contracts/max_in_list.tz | 10 +++++----- test/contracts/originator.tz | 8 ++++---- test/contracts/ret_int.tz | 4 ++-- test/contracts/steps_to_quota.tz | 2 +- test/contracts/weather_insurance.tz | 4 ++-- test/test-utils.sh | 2 ++ 8 files changed, 25 insertions(+), 24 deletions(-) diff --git a/test/contracts/build_list.tz b/test/contracts/build_list.tz index ce08aa4e8..e2ccfd4bf 100644 --- a/test/contracts/build_list.tz +++ b/test/contracts/build_list.tz @@ -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}; diff --git a/test/contracts/hardlimit.tz b/test/contracts/hardlimit.tz index 8099fd538..86cf0caf5 100644 --- a/test/contracts/hardlimit.tz +++ b/test/contracts/hardlimit.tz @@ -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 \ No newline at end of file +storage int diff --git a/test/contracts/max_in_list.tz b/test/contracts/max_in_list.tz index fb73b44dd..65a8ce4c6 100644 --- a/test/contracts/max_in_list.tz +++ b/test/contracts/max_in_list.tz @@ -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}; diff --git a/test/contracts/originator.tz b/test/contracts/originator.tz index bb1460e51..50e02a784 100644 --- a/test/contracts/originator.tz +++ b/test/contracts/originator.tz @@ -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 } diff --git a/test/contracts/ret_int.tz b/test/contracts/ret_int.tz index 05b2fa622..e6415d413 100644 --- a/test/contracts/ret_int.tz +++ b/test/contracts/ret_int.tz @@ -1,4 +1,4 @@ parameter unit; -code {CAR; PUSH uint32 300; PAIR}; -return uint32; +code {CAR; PUSH nat 300; PAIR}; +return nat; storage unit; diff --git a/test/contracts/steps_to_quota.tz b/test/contracts/steps_to_quota.tz index 69991f36b..35a1cea7e 100644 --- a/test/contracts/steps_to_quota.tz +++ b/test/contracts/steps_to_quota.tz @@ -1,4 +1,4 @@ parameter unit; -return uint32; +return nat; storage unit; code {DROP; UNIT; STEPS_TO_QUOTA; PAIR}; diff --git a/test/contracts/weather_insurance.tz b/test/contracts/weather_insurance.tz index 5eaa7bed7..f934c88fc 100644 --- a/test/contracts/weather_insurance.tz +++ b/test/contracts/weather_insurance.tz @@ -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; diff --git a/test/test-utils.sh b/test/test-utils.sh index 5606d9f6a..242e743f5 100755 --- a/test/test-utils.sh +++ b/test/test-utils.sh @@ -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}"