Client: reorg Michelson test contracts and bash scripts (macros, pt2)

This commit is contained in:
b 2018-10-29 18:54:59 +01:00 committed by Benjamin Canou
parent 3c1f5702e1
commit 2f58e86fa8
No known key found for this signature in database
GPG Key ID: 73607948459DC5F8
10 changed files with 108 additions and 206 deletions

View File

@ -31,29 +31,12 @@ if [ ! $NO_TYPECHECK ] ; then
fi fi
# Build list
#assert_storage $contract_dir/build_list.tz '{}' 0 "{ 0 }"
#assert_storage $contract_dir/build_list.tz '{}' 3 "{ 0 ; 1 ; 2 ; 3 }"
#assert_storage $contract_dir/build_list.tz '{}' 10 \
# "{ 0 ; 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; 10 }"
# Concatenate all strings of a list into one string # Concatenate all strings of a list into one string
#assert_storage $contract_dir/concat_list.tz '""' '{ "a" ; "b" ; "c" }' '"abc"' #assert_storage $contract_dir/concat_list.tz '""' '{ "a" ; "b" ; "c" }' '"abc"'
#assert_storage $contract_dir/concat_list.tz '""' '{}' '""' #assert_storage $contract_dir/concat_list.tz '""' '{}' '""'
#assert_storage $contract_dir/concat_list.tz \ #assert_storage $contract_dir/concat_list.tz \
# '""' '{ "Hello" ; " " ; "World" ; "!" }' '"Hello World!"' # '""' '{ "Hello" ; " " ; "World" ; "!" }' '"Hello World!"'
# Find maximum int in list -- returns None if not found
assert_storage $contract_dir/max_in_list.tz None '{}' 'None'
assert_storage $contract_dir/max_in_list.tz None '{ 1 }' '(Some 1)'
assert_storage $contract_dir/max_in_list.tz None '{ -1 }' '(Some -1)'
assert_storage $contract_dir/max_in_list.tz None \
'{ 10 ; -1 ; -20 ; 100 ; 0 }' '(Some 100)'
assert_storage $contract_dir/max_in_list.tz None \
'{ 10 ; -1 ; -20 ; 100 ; 0 }' '(Some 100)'
assert_storage $contract_dir/max_in_list.tz None \
'{ -10 ; -1 ; -20 ; -100 }' '(Some -1)'
# Typing gas bounds checks # Typing gas bounds checks
assert_fails $client originate contract first_explosion for bootstrap1 \ assert_fails $client originate contract first_explosion for bootstrap1 \
@ -68,77 +51,6 @@ assert_fails $client run script '{parameter (list int);storage (list (list (lis
on storage '{}' \ on storage '{}' \
and input '{1;2;3;4;5;6;7;8;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1}' and input '{1;2;3;4;5;6;7;8;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1}'
# Test comparisons on tez { EQ ; GT ; LT ; GE ; LE }
#assert_storage $contract_dir/compare.tz '{}' '(Pair 1000000 2000000)' '{ False ; False ; True ; False ; True }'
#assert_storage $contract_dir/compare.tz '{}' '(Pair 2000000 1000000)' '{ False ; True ; False ; True ; False }'
#assert_storage $contract_dir/compare.tz '{}' '(Pair 2370000 2370000)' '{ True ; False ; False ; True ; True }'
# Test ASSERT
#assert_storage $contract_dir/assert.tz Unit True Unit
#assert_fails $client run script $contract_dir/assert.tz on storage Unit and input False
# COMPARE; ASSERT_
#assert_storage $contract_dir/assert_eq.tz Unit '(Pair -1 -1)' Unit
#assert_fails $client run script $contract_dir/assert_eq.tz on storage Unit and input '(Pair 0 -1)'
#assert_storage $contract_dir/assert_eq.tz Unit '(Pair -1 -1)' Unit
#assert_fails $client run script $contract_dir/assert_eq.tz on storage Unit and input '(Pair 0 -1)'
#assert_storage $contract_dir/assert_neq.tz Unit '(Pair 0 -1)' Unit
#assert_fails $client run script $contract_dir/assert_neq.tz on storage Unit and input '(Pair -1 -1)'
#assert_storage $contract_dir/assert_lt.tz Unit '(Pair -1 0)' Unit
#assert_fails $client run script $contract_dir/assert_lt.tz on storage Unit and input '(Pair 0 -1)'
#assert_fails $client run script $contract_dir/assert_lt.tz on storage Unit and input '(Pair 0 0)'
#assert_storage $contract_dir/assert_le.tz Unit '(Pair 0 0)' Unit
#assert_storage $contract_dir/assert_le.tz Unit '(Pair -1 0)' Unit
#assert_fails $client run script $contract_dir/assert_le.tz on storage Unit and input '(Pair 0 -1)'
#assert_storage $contract_dir/assert_gt.tz Unit '(Pair 0 -1)' Unit
#assert_fails $client run script $contract_dir/assert_gt.tz on storage Unit and input '(Pair -1 0)'
#assert_fails $client run script $contract_dir/assert_gt.tz on storage Unit and input '(Pair 0 0)'
#assert_storage $contract_dir/assert_ge.tz Unit '(Pair 0 0)' Unit
#assert_storage $contract_dir/assert_ge.tz Unit '(Pair 0 -1)' Unit
#assert_fails $client run script $contract_dir/assert_ge.tz on storage Unit and input '(Pair -1 0)'
# ASSERT_CMP
#assert_storage $contract_dir/assert_cmpeq.tz Unit '(Pair -1 -1)' Unit
#assert_fails $client run script $contract_dir/assert_cmpeq.tz on storage Unit and input '(Pair 0 -1)'
#assert_storage $contract_dir/assert_cmpeq.tz Unit '(Pair -1 -1)' Unit
#assert_fails $client run script $contract_dir/assert_cmpeq.tz on storage Unit and input '(Pair 0 -1)'
#assert_storage $contract_dir/assert_cmpneq.tz Unit '(Pair 0 -1)' Unit
#assert_fails $client run script $contract_dir/assert_cmpneq.tz on storage Unit and input '(Pair -1 -1)'
#assert_storage $contract_dir/assert_cmplt.tz Unit '(Pair -1 0)' Unit
#assert_fails $client run script $contract_dir/assert_cmplt.tz on storage Unit and input '(Pair 0 -1)'
#assert_fails $client run script $contract_dir/assert_cmplt.tz on storage Unit and input '(Pair 0 0)'
#assert_storage $contract_dir/assert_cmple.tz Unit '(Pair 0 0)' Unit
#assert_storage $contract_dir/assert_cmple.tz Unit '(Pair -1 0)' Unit
#assert_fails $client run script $contract_dir/assert_cmple.tz on storage Unit and input '(Pair 0 -1)'
#assert_storage $contract_dir/assert_cmpgt.tz Unit '(Pair 0 -1)' Unit
#assert_fails $client run script $contract_dir/assert_cmpgt.tz on storage Unit and input '(Pair -1 0)'
#assert_fails $client run script $contract_dir/assert_cmpgt.tz on storage Unit and input '(Pair 0 0)'
#assert_storage $contract_dir/assert_cmpge.tz Unit '(Pair 0 0)' Unit
#assert_storage $contract_dir/assert_cmpge.tz Unit '(Pair 0 -1)' Unit
#assert_fails $client run script $contract_dir/assert_cmpge.tz on storage Unit and input '(Pair -1 0)'
# Tests the SET_CAR and SET_CDR instructions (macros)
assert_storage $contract_dir/set_caddaadr.tz \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 0) 4) 5))) 6)' \
'3000000' \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 3000000) 4) 5))) 6)'
assert_storage $contract_dir/map_caddaadr.tz \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 0) 4) 5))) 6)' \
'Unit' \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 1000000) 4) 5))) 6)'
# Test replay prevention # Test replay prevention
init_with_transfer $contract_dir/replay.tz $key2 Unit 0 bootstrap1 init_with_transfer $contract_dir/replay.tz $key2 Unit 0 bootstrap1
@ -189,12 +101,6 @@ assert_success $client transfer 0 from bootstrap1 to reveal_signed_preimage -arg
'(Pair 0x050100000027566f756c657a2d766f757320636f75636865722061766563206d6f692c20636520736f6972203f "p2sigsceCzcDw2AeYDzUonj4JT341WC9Px4wdhHBxbZcG1FhfqFVuG7f2fGCzrEHSAZgrsrQWpxduDPk9qZRgrpzwJnSHC3gZJ")' '(Pair 0x050100000027566f756c657a2d766f757320636f75636865722061766563206d6f692c20636520736f6972203f "p2sigsceCzcDw2AeYDzUonj4JT341WC9Px4wdhHBxbZcG1FhfqFVuG7f2fGCzrEHSAZgrsrQWpxduDPk9qZRgrpzwJnSHC3gZJ")'
bake bake
# Test comparisons on bytes { EQ ; GT ; LT ; GE ; LE }
#assert_storage $contract_dir/compare_bytes.tz '{}' '(Pair 0x33 0x34)' '{ False ; False ; True ; False ; True }'
#assert_storage $contract_dir/compare_bytes.tz '{}' '(Pair 0x33 0x33aa)' '{ False ; False ; True ; False ; True }'
#assert_storage $contract_dir/compare_bytes.tz '{}' '(Pair 0x33 0x33)' '{ True ; False ; False ; True ; True }'
#assert_storage $contract_dir/compare_bytes.tz '{}' '(Pair 0x34 0x33)' '{ False ; True ; False ; True ; False }'
# Test SET_DELEGATE # Test SET_DELEGATE
#b2='tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN' #b2='tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN'
@ -243,36 +149,6 @@ assert_fails $client typecheck data '{ "A" ; "B" ; "B" }' against type '(set str
#assert_fails $client transfer 0 from bootstrap3 to guestbook -arg '"Pas moi non plus"' #assert_fails $client transfer 0 from bootstrap3 to guestbook -arg '"Pas moi non plus"'
#assert_fails $client transfer 0 from bootstrap1 to guestbook -arg '"Recoucou ?"' #assert_fails $client transfer 0 from bootstrap1 to guestbook -arg '"Recoucou ?"'
# Test for big maps
#init_with_transfer $contract_dir/big_map_mem.tz $key1\
# '(Pair { Elt 1 Unit ; Elt 2 Unit ; Elt 3 Unit } Unit)' \
# 100 bootstrap1
#bake_after $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 0 False)'
#assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 0 True)'
#bake_after $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 1 True)'
#assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 1 False)'
#bake_after $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 2 True)'
#assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 2 False)'
#bake_after $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 3 True)'
#assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 3 False)'
#bake_after $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 4 False)'
#assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 4 True)'
#assert_fails $client typecheck data '3' against type \
# '(int @aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)'
#$client typecheck data '3' against type \
# '(int @aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)'
#init_with_transfer $contract_dir/big_map_get_add.tz $key1\
# '(Pair { Elt 0 1 ; Elt 1 2 ; Elt 2 3 } Unit)' \
# 100 bootstrap1
#bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 200 (Some 2)) (Pair 200 (Some 2)))'
#bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 200 None) (Pair 200 None))'
#bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 200 None) (Pair 300 None))'
#bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 1 None) (Pair 200 None))'
#bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 1 (Some 2)) (Pair 0 (Some 1)))'
#bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 400 (Some 1232)) (Pair 400 (Some 1232)))'
#bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 401 (Some 0)) (Pair 400 (Some 1232)))'
# Test for issue #262 # Test for issue #262
tee /tmp/bug_262.tz <<EOF tee /tmp/bug_262.tz <<EOF

View File

@ -1,3 +1,4 @@
#!/bin/bash
set -e set -e
set -o pipefail set -o pipefail
@ -29,78 +30,114 @@ if [ ! $NO_TYPECHECK ] ; then
printf "All contracts are well typed\n\n" printf "All contracts are well typed\n\n"
fi fi
# ASSERT_CMP # TODO macro_annotations.tz, min.tz, pair_macro.tz, take_my_money.tz, unpair_macro.tz
assert_storage $contract_macros_dir/assert_cmpeq.tz Unit '(Pair -1 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_cmpeq.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_macros_dir/assert_cmpeq.tz Unit '(Pair -1 -1)' Unit # FORMAT: assert_output contract_file storage input expected_result
assert_fails $client run script $contract_macros_dir/assert_cmpeq.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_macros_dir/assert_cmpge.tz Unit '(Pair 0 0)' Unit # Build list
assert_storage $contract_macros_dir/assert_cmpge.tz Unit '(Pair 0 -1)' Unit assert_storage $contract_macros_dir/build_list.tz '{}' 0 "{ 0 }"
assert_fails $client run script $contract_macros_dir/assert_cmpge.tz on storage Unit and input '(Pair -1 0)' assert_storage $contract_macros_dir/build_list.tz '{}' 3 "{ 0 ; 1 ; 2 ; 3 }"
assert_storage $contract_macros_dir/build_list.tz '{}' 10 \
"{ 0 ; 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; 10 }"
assert_storage $contract_macros_dir/assert_cmpgt.tz Unit '(Pair 0 -1)' Unit # Find maximum int in list -- returns None if not found
assert_fails $client run script $contract_macros_dir/assert_cmpgt.tz on storage Unit and input '(Pair -1 0)' assert_storage $contract_macros_dir/max_in_list.tz None '{}' 'None'
assert_fails $client run script $contract_macros_dir/assert_cmpgt.tz on storage Unit and input '(Pair 0 0)' assert_storage $contract_macros_dir/max_in_list.tz None '{ 1 }' '(Some 1)'
assert_storage $contract_macros_dir/max_in_list.tz None '{ -1 }' '(Some -1)'
assert_storage $contract_macros_dir/max_in_list.tz None \
'{ 10 ; -1 ; -20 ; 100 ; 0 }' '(Some 100)'
assert_storage $contract_macros_dir/max_in_list.tz None \
'{ 10 ; -1 ; -20 ; 100 ; 0 }' '(Some 100)'
assert_storage $contract_macros_dir/max_in_list.tz None \
'{ -10 ; -1 ; -20 ; -100 }' '(Some -1)'
assert_storage $contract_macros_dir/assert_cmple.tz Unit '(Pair 0 0)' Unit # Test comparisons on tez { EQ ; GT ; LT ; GE ; LE }
assert_storage $contract_macros_dir/assert_cmple.tz Unit '(Pair -1 0)' Unit assert_storage $contract_macros_dir/compare.tz '{}' '(Pair 1000000 2000000)' '{ False ; False ; True ; False ; True }'
assert_fails $client run script $contract_macros_dir/assert_cmple.tz on storage Unit and input '(Pair 0 -1)' assert_storage $contract_macros_dir/compare.tz '{}' '(Pair 2000000 1000000)' '{ False ; True ; False ; True ; False }'
assert_storage $contract_macros_dir/compare.tz '{}' '(Pair 2370000 2370000)' '{ True ; False ; False ; True ; True }'
assert_storage $contract_macros_dir/assert_cmplt.tz Unit '(Pair -1 0)' Unit
assert_fails $client run script $contract_macros_dir/assert_cmplt.tz on storage Unit and input '(Pair 0 -1)'
assert_fails $client run script $contract_macros_dir/assert_cmplt.tz on storage Unit and input '(Pair 0 0)'
assert_storage $contract_macros_dir/assert_cmpneq.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_cmpneq.tz on storage Unit and input '(Pair -1 -1)'
# COMPARE; ASSERT_
assert_storage $contract_macros_dir/assert_eq.tz Unit '(Pair -1 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_eq.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_macros_dir/assert_eq.tz Unit '(Pair -1 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_eq.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_macros_dir/assert_ge.tz Unit '(Pair 0 0)' Unit
assert_storage $contract_macros_dir/assert_ge.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_ge.tz on storage Unit and input '(Pair -1 0)'
assert_storage $contract_macros_dir/assert_gt.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_gt.tz on storage Unit and input '(Pair -1 0)'
assert_fails $client run script $contract_macros_dir/assert_gt.tz on storage Unit and input '(Pair 0 0)'
assert_storage $contract_macros_dir/assert_le.tz Unit '(Pair 0 0)' Unit
assert_storage $contract_macros_dir/assert_le.tz Unit '(Pair -1 0)' Unit
assert_fails $client run script $contract_macros_dir/assert_le.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_macros_dir/assert_lt.tz Unit '(Pair -1 0)' Unit
assert_fails $client run script $contract_macros_dir/assert_lt.tz on storage Unit and input '(Pair 0 -1)'
assert_fails $client run script $contract_macros_dir/assert_lt.tz on storage Unit and input '(Pair 0 0)'
assert_storage $contract_macros_dir/assert_neq.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_neq.tz on storage Unit and input '(Pair -1 -1)'
# Test ASSERT # Test ASSERT
assert_storage $contract_macros_dir/assert.tz Unit True Unit assert_storage $contract_macros_dir/assert.tz Unit True Unit
assert_fails $client run script $contract_macros_dir/assert.tz on storage Unit and input False assert_fails $client run script $contract_macros_dir/assert.tz on storage Unit and input False
# ASSERT_{OP}
assert_storage $contract_macros_dir/assert_eq.tz Unit '(Pair -1 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_eq.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_macros_dir/assert_eq.tz Unit '(Pair -1 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_eq.tz on storage Unit and input '(Pair 0 -1)'
# Test for big map get add assert_storage $contract_macros_dir/assert_neq.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_neq.tz on storage Unit and input '(Pair -1 -1)'
init_with_transfer $contract_macros_dir/big_map_get_add.tz $key1\ assert_storage $contract_macros_dir/assert_lt.tz Unit '(Pair -1 0)' Unit
'(Pair { Elt 0 1 ; Elt 1 2 ; Elt 2 3 } Unit)' \ assert_fails $client run script $contract_macros_dir/assert_lt.tz on storage Unit and input '(Pair 0 -1)'
assert_fails $client run script $contract_macros_dir/assert_lt.tz on storage Unit and input '(Pair 0 0)'
assert_storage $contract_macros_dir/assert_le.tz Unit '(Pair 0 0)' Unit
assert_storage $contract_macros_dir/assert_le.tz Unit '(Pair -1 0)' Unit
assert_fails $client run script $contract_macros_dir/assert_le.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_macros_dir/assert_gt.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_gt.tz on storage Unit and input '(Pair -1 0)'
assert_fails $client run script $contract_macros_dir/assert_gt.tz on storage Unit and input '(Pair 0 0)'
assert_storage $contract_macros_dir/assert_ge.tz Unit '(Pair 0 0)' Unit
assert_storage $contract_macros_dir/assert_ge.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_ge.tz on storage Unit and input '(Pair -1 0)'
# ASSERT_CMP{OP}
assert_storage $contract_macros_dir/assert_cmpeq.tz Unit '(Pair -1 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_cmpeq.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_macros_dir/assert_cmpneq.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_cmpneq.tz on storage Unit and input '(Pair -1 -1)'
assert_storage $contract_macros_dir/assert_cmplt.tz Unit '(Pair -1 0)' Unit
assert_fails $client run script $contract_macros_dir/assert_cmplt.tz on storage Unit and input '(Pair 0 0)'
assert_fails $client run script $contract_macros_dir/assert_cmplt.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_macros_dir/assert_cmple.tz Unit '(Pair -1 0)' Unit
assert_storage $contract_macros_dir/assert_cmple.tz Unit '(Pair 0 0)' Unit
assert_fails $client run script $contract_macros_dir/assert_cmple.tz on storage Unit and input '(Pair 0 -1)'
assert_storage $contract_macros_dir/assert_cmpgt.tz Unit '(Pair 0 -1)' Unit
assert_fails $client run script $contract_macros_dir/assert_cmpgt.tz on storage Unit and input '(Pair 0 0)'
assert_fails $client run script $contract_macros_dir/assert_cmpgt.tz on storage Unit and input '(Pair -1 0)'
assert_storage $contract_macros_dir/assert_cmpge.tz Unit '(Pair 0 -1)' Unit
assert_storage $contract_macros_dir/assert_cmpge.tz Unit '(Pair 0 0)' Unit
assert_fails $client run script $contract_macros_dir/assert_cmpge.tz on storage Unit and input '(Pair -1 0)'
# Tests the SET_CAR and SET_CDR instructions
assert_storage $contract_macros_dir/set_caddaadr.tz \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 0) 4) 5))) 6)' \
'3000000' \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 3000000) 4) 5))) 6)'
assert_storage $contract_macros_dir/map_caddaadr.tz \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 0) 4) 5))) 6)' \
'Unit' \
'(Pair (Pair 1 (Pair 2 (Pair (Pair (Pair 3 1000000) 4) 5))) 6)'
# Test comparisons on bytes { EQ ; GT ; LT ; GE ; LE }
assert_storage $contract_macros_dir/compare_bytes.tz '{}' '(Pair 0x33 0x34)' '{ False ; False ; True ; False ; True }'
assert_storage $contract_macros_dir/compare_bytes.tz '{}' '(Pair 0x33 0x33aa)' '{ False ; False ; True ; False ; True }'
assert_storage $contract_macros_dir/compare_bytes.tz '{}' '(Pair 0x33 0x33)' '{ True ; False ; False ; True ; True }'
assert_storage $contract_macros_dir/compare_bytes.tz '{}' '(Pair 0x34 0x33)' '{ False ; True ; False ; True ; False }'
# Test goldenbook
init_with_transfer $contract_macros_dir/guestbook.tz $key1\
'{ Elt "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" None }' \
100 bootstrap1 100 bootstrap1
assert_fails $client transfer 0 from bootstrap2 to guestbook -arg '"Pas moi"'
bake_after $client transfer 0 from bootstrap1 to guestbook -arg '"Coucou"'
assert_storage_contains guestbook '{ Elt "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" (Some "Coucou") }'
assert_fails $client transfer 0 from bootstrap3 to guestbook -arg '"Pas moi non plus"'
assert_fails $client transfer 0 from bootstrap1 to guestbook -arg '"Recoucou ?"'
bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 200 (Some 2)) (Pair 200 (Some 2)))' # Test for big maps
bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 200 None) (Pair 200 None))'
bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 200 None) (Pair 300 None))'
bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 1 None) (Pair 200 None))'
bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 1 (Some 2)) (Pair 0 (Some 1)))'
bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 400 (Some 1232)) (Pair 400 (Some 1232)))'
bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 401 (Some 0)) (Pair 400 (Some 1232)))'
# Test for big maps member
init_with_transfer $contract_macros_dir/big_map_mem.tz $key1\ init_with_transfer $contract_macros_dir/big_map_mem.tz $key1\
'(Pair { Elt 1 Unit ; Elt 2 Unit ; Elt 3 Unit } Unit)' \ '(Pair { Elt 1 Unit ; Elt 2 Unit ; Elt 3 Unit } Unit)' \
100 bootstrap1 100 bootstrap1
@ -119,29 +156,18 @@ assert_fails $client typecheck data '3' against type \
$client typecheck data '3' against type \ $client typecheck data '3' against type \
'(int @aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)' '(int @aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)'
# Build list init_with_transfer $contract_macros_dir/big_map_get_add.tz $key1\
assert_storage $contract_macros_dir/build_list.tz '{}' 0 "{ 0 }" '(Pair { Elt 0 1 ; Elt 1 2 ; Elt 2 3 } Unit)' \
assert_storage $contract_macros_dir/build_list.tz '{}' 3 "{ 0 ; 1 ; 2 ; 3 }"
assert_storage $contract_macros_dir/build_list.tz '{}' 10 \
"{ 0 ; 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; 10 }"
# Test comparisons on bytes { EQ ; GT ; LT ; GE ; LE }
assert_storage $contract_macros_dir/compare_bytes.tz '{}' '(Pair 0x33 0x34)' '{ False ; False ; True ; False ; True }'
assert_storage $contract_macros_dir/compare_bytes.tz '{}' '(Pair 0x33 0x33aa)' '{ False ; False ; True ; False ; True }'
assert_storage $contract_macros_dir/compare_bytes.tz '{}' '(Pair 0x33 0x33)' '{ True ; False ; False ; True ; True }'
assert_storage $contract_macros_dir/compare_bytes.tz '{}' '(Pair 0x34 0x33)' '{ False ; True ; False ; True ; False }'
# Test comparisons on tez { EQ ; GT ; LT ; GE ; LE }
assert_storage $contract_macros_dir/compare.tz '{}' '(Pair 1000000 2000000)' '{ False ; False ; True ; False ; True }'
assert_storage $contract_macros_dir/compare.tz '{}' '(Pair 2000000 1000000)' '{ False ; True ; False ; True ; False }'
assert_storage $contract_macros_dir/compare.tz '{}' '(Pair 2370000 2370000)' '{ True ; False ; False ; True ; True }'
# Test goldenbook
init_with_transfer $contract_macros_dir/guestbook.tz $key1\
'{ Elt "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" None }' \
100 bootstrap1 100 bootstrap1
assert_fails $client transfer 0 from bootstrap2 to guestbook -arg '"Pas moi"'
bake_after $client transfer 0 from bootstrap1 to guestbook -arg '"Coucou"' bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 200 (Some 2)) (Pair 200 (Some 2)))'
assert_storage_contains guestbook '{ Elt "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" (Some "Coucou") }' bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 200 None) (Pair 200 None))'
assert_fails $client transfer 0 from bootstrap3 to guestbook -arg '"Pas moi non plus"' bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 200 None) (Pair 300 None))'
assert_fails $client transfer 0 from bootstrap1 to guestbook -arg '"Recoucou ?"' bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 1 None) (Pair 200 None))'
bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 1 (Some 2)) (Pair 0 (Some 1)))'
bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 400 (Some 1232)) (Pair 400 (Some 1232)))'
bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 401 (Some 0)) (Pair 400 (Some 1232)))'
printf "\nEnd of test\n"
show_logs="no"