diff --git a/src/bin_client/test/contracts/accounts.tz b/src/bin_client/test/contracts_attic/accounts.tz similarity index 100% rename from src/bin_client/test/contracts/accounts.tz rename to src/bin_client/test/contracts_attic/accounts.tz diff --git a/src/bin_client/test/contracts/add1.tz b/src/bin_client/test/contracts_attic/add1.tz similarity index 100% rename from src/bin_client/test/contracts/add1.tz rename to src/bin_client/test/contracts_attic/add1.tz diff --git a/src/bin_client/test/contracts/add1_list.tz b/src/bin_client/test/contracts_attic/add1_list.tz similarity index 100% rename from src/bin_client/test/contracts/add1_list.tz rename to src/bin_client/test/contracts_attic/add1_list.tz diff --git a/src/bin_client/test/contracts/after_strategy.tz b/src/bin_client/test/contracts_attic/after_strategy.tz similarity index 100% rename from src/bin_client/test/contracts/after_strategy.tz rename to src/bin_client/test/contracts_attic/after_strategy.tz diff --git a/src/bin_client/test/contracts/always.tz b/src/bin_client/test/contracts_attic/always.tz similarity index 100% rename from src/bin_client/test/contracts/always.tz rename to src/bin_client/test/contracts_attic/always.tz diff --git a/src/bin_client/test/contracts/append.tz b/src/bin_client/test/contracts_attic/append.tz similarity index 100% rename from src/bin_client/test/contracts/append.tz rename to src/bin_client/test/contracts_attic/append.tz diff --git a/src/bin_client/test/contracts/at_least.tz b/src/bin_client/test/contracts_attic/at_least.tz similarity index 100% rename from src/bin_client/test/contracts/at_least.tz rename to src/bin_client/test/contracts_attic/at_least.tz diff --git a/src/bin_client/test/contracts/auction.tz b/src/bin_client/test/contracts_attic/auction.tz similarity index 100% rename from src/bin_client/test/contracts/auction.tz rename to src/bin_client/test/contracts_attic/auction.tz diff --git a/src/bin_client/test/contracts/bad_lockup.tz b/src/bin_client/test/contracts_attic/bad_lockup.tz similarity index 100% rename from src/bin_client/test/contracts/bad_lockup.tz rename to src/bin_client/test/contracts_attic/bad_lockup.tz diff --git a/src/bin_client/test/contracts/big_map_union.tz b/src/bin_client/test/contracts_attic/big_map_union.tz similarity index 100% rename from src/bin_client/test/contracts/big_map_union.tz rename to src/bin_client/test/contracts_attic/big_map_union.tz diff --git a/src/bin_client/test/contracts/cadr_annotation.tz b/src/bin_client/test/contracts_attic/cadr_annotation.tz similarity index 100% rename from src/bin_client/test/contracts/cadr_annotation.tz rename to src/bin_client/test/contracts_attic/cadr_annotation.tz diff --git a/src/bin_client/test/contracts/concat.tz b/src/bin_client/test/contracts_attic/concat.tz similarity index 100% rename from src/bin_client/test/contracts/concat.tz rename to src/bin_client/test/contracts_attic/concat.tz diff --git a/src/bin_client/test/contracts/conditionals.tz b/src/bin_client/test/contracts_attic/conditionals.tz similarity index 100% rename from src/bin_client/test/contracts/conditionals.tz rename to src/bin_client/test/contracts_attic/conditionals.tz diff --git a/src/bin_client/test/contracts/cons_twice.tz b/src/bin_client/test/contracts_attic/cons_twice.tz similarity index 100% rename from src/bin_client/test/contracts/cons_twice.tz rename to src/bin_client/test/contracts_attic/cons_twice.tz diff --git a/src/bin_client/test/contracts/cps_fact.tz b/src/bin_client/test/contracts_attic/cps_fact.tz similarity index 100% rename from src/bin_client/test/contracts/cps_fact.tz rename to src/bin_client/test/contracts_attic/cps_fact.tz diff --git a/src/bin_client/test/contracts/create_add1_lists.tz b/src/bin_client/test/contracts_attic/create_add1_lists.tz similarity index 100% rename from src/bin_client/test/contracts/create_add1_lists.tz rename to src/bin_client/test/contracts_attic/create_add1_lists.tz diff --git a/src/bin_client/test/contracts/data_publisher.tz b/src/bin_client/test/contracts_attic/data_publisher.tz similarity index 100% rename from src/bin_client/test/contracts/data_publisher.tz rename to src/bin_client/test/contracts_attic/data_publisher.tz diff --git a/src/bin_client/test/contracts/dispatch.tz b/src/bin_client/test/contracts_attic/dispatch.tz similarity index 100% rename from src/bin_client/test/contracts/dispatch.tz rename to src/bin_client/test/contracts_attic/dispatch.tz diff --git a/src/bin_client/test/contracts/empty.tz b/src/bin_client/test/contracts_attic/empty.tz similarity index 100% rename from src/bin_client/test/contracts/empty.tz rename to src/bin_client/test/contracts_attic/empty.tz diff --git a/src/bin_client/test/contracts/fail_amount.tz b/src/bin_client/test/contracts_attic/fail_amount.tz similarity index 100% rename from src/bin_client/test/contracts/fail_amount.tz rename to src/bin_client/test/contracts_attic/fail_amount.tz diff --git a/src/bin_client/test/contracts/faucet.tz b/src/bin_client/test/contracts_attic/faucet.tz similarity index 100% rename from src/bin_client/test/contracts/faucet.tz rename to src/bin_client/test/contracts_attic/faucet.tz diff --git a/src/bin_client/test/contracts/forward.tz b/src/bin_client/test/contracts_attic/forward.tz similarity index 100% rename from src/bin_client/test/contracts/forward.tz rename to src/bin_client/test/contracts_attic/forward.tz diff --git a/src/bin_client/test/contracts/id.tz b/src/bin_client/test/contracts_attic/id.tz similarity index 100% rename from src/bin_client/test/contracts/id.tz rename to src/bin_client/test/contracts_attic/id.tz diff --git a/src/bin_client/test/contracts/infinite_loop.tz b/src/bin_client/test/contracts_attic/infinite_loop.tz similarity index 100% rename from src/bin_client/test/contracts/infinite_loop.tz rename to src/bin_client/test/contracts_attic/infinite_loop.tz diff --git a/src/bin_client/test/contracts/insertion_sort.tz b/src/bin_client/test/contracts_attic/insertion_sort.tz similarity index 100% rename from src/bin_client/test/contracts/insertion_sort.tz rename to src/bin_client/test/contracts_attic/insertion_sort.tz diff --git a/src/bin_client/test/contracts/int_publisher.tz b/src/bin_client/test/contracts_attic/int_publisher.tz similarity index 100% rename from src/bin_client/test/contracts/int_publisher.tz rename to src/bin_client/test/contracts_attic/int_publisher.tz diff --git a/src/bin_client/test/contracts/king_of_tez.tz b/src/bin_client/test/contracts_attic/king_of_tez.tz similarity index 100% rename from src/bin_client/test/contracts/king_of_tez.tz rename to src/bin_client/test/contracts_attic/king_of_tez.tz diff --git a/src/bin_client/test/contracts_opcode/assert.tz b/src/bin_client/test/contracts_macros/assert.tz similarity index 100% rename from src/bin_client/test/contracts_opcode/assert.tz rename to src/bin_client/test/contracts_macros/assert.tz diff --git a/src/bin_client/test/contracts_opcode/assert_cmpeq.tz b/src/bin_client/test/contracts_macros/assert_cmpeq.tz similarity index 100% rename from src/bin_client/test/contracts_opcode/assert_cmpeq.tz rename to src/bin_client/test/contracts_macros/assert_cmpeq.tz diff --git a/src/bin_client/test/contracts_opcode/assert_cmpge.tz b/src/bin_client/test/contracts_macros/assert_cmpge.tz similarity index 100% rename from src/bin_client/test/contracts_opcode/assert_cmpge.tz rename to src/bin_client/test/contracts_macros/assert_cmpge.tz diff --git a/src/bin_client/test/contracts_opcode/assert_cmpgt.tz b/src/bin_client/test/contracts_macros/assert_cmpgt.tz similarity index 100% rename from src/bin_client/test/contracts_opcode/assert_cmpgt.tz rename to src/bin_client/test/contracts_macros/assert_cmpgt.tz diff --git a/src/bin_client/test/contracts_opcode/assert_cmple.tz b/src/bin_client/test/contracts_macros/assert_cmple.tz similarity index 100% rename from src/bin_client/test/contracts_opcode/assert_cmple.tz rename to src/bin_client/test/contracts_macros/assert_cmple.tz diff --git a/src/bin_client/test/contracts_opcode/assert_cmplt.tz b/src/bin_client/test/contracts_macros/assert_cmplt.tz similarity index 100% rename from src/bin_client/test/contracts_opcode/assert_cmplt.tz rename to src/bin_client/test/contracts_macros/assert_cmplt.tz diff --git a/src/bin_client/test/contracts_opcode/assert_cmpneq.tz b/src/bin_client/test/contracts_macros/assert_cmpneq.tz similarity index 100% rename from src/bin_client/test/contracts_opcode/assert_cmpneq.tz rename to src/bin_client/test/contracts_macros/assert_cmpneq.tz diff --git a/src/bin_client/test/contracts_opcode/assert_eq.tz b/src/bin_client/test/contracts_macros/assert_eq.tz similarity index 100% rename from src/bin_client/test/contracts_opcode/assert_eq.tz rename to src/bin_client/test/contracts_macros/assert_eq.tz diff --git a/src/bin_client/test/contracts_opcode/assert_ge.tz b/src/bin_client/test/contracts_macros/assert_ge.tz similarity index 100% rename from src/bin_client/test/contracts_opcode/assert_ge.tz rename to src/bin_client/test/contracts_macros/assert_ge.tz diff --git a/src/bin_client/test/contracts_opcode/assert_gt.tz b/src/bin_client/test/contracts_macros/assert_gt.tz similarity index 100% rename from src/bin_client/test/contracts_opcode/assert_gt.tz rename to src/bin_client/test/contracts_macros/assert_gt.tz diff --git a/src/bin_client/test/contracts_opcode/assert_le.tz b/src/bin_client/test/contracts_macros/assert_le.tz similarity index 100% rename from src/bin_client/test/contracts_opcode/assert_le.tz rename to src/bin_client/test/contracts_macros/assert_le.tz diff --git a/src/bin_client/test/contracts_opcode/assert_lt.tz b/src/bin_client/test/contracts_macros/assert_lt.tz similarity index 100% rename from src/bin_client/test/contracts_opcode/assert_lt.tz rename to src/bin_client/test/contracts_macros/assert_lt.tz diff --git a/src/bin_client/test/contracts_opcode/assert_neq.tz b/src/bin_client/test/contracts_macros/assert_neq.tz similarity index 100% rename from src/bin_client/test/contracts_opcode/assert_neq.tz rename to src/bin_client/test/contracts_macros/assert_neq.tz diff --git a/src/bin_client/test/contracts/fail.tz b/src/bin_client/test/contracts_macros/fail.tz similarity index 100% rename from src/bin_client/test/contracts/fail.tz rename to src/bin_client/test/contracts_macros/fail.tz diff --git a/src/bin_client/test/contracts_macros/create_account.tz b/src/bin_client/test/contracts_mini_scenarios/create_account.tz similarity index 100% rename from src/bin_client/test/contracts_macros/create_account.tz rename to src/bin_client/test/contracts_mini_scenarios/create_account.tz diff --git a/src/bin_client/test/contracts_macros/add_delta_timestamp.tz b/src/bin_client/test/contracts_opcode/add_delta_timestamp.tz similarity index 100% rename from src/bin_client/test/contracts_macros/add_delta_timestamp.tz rename to src/bin_client/test/contracts_opcode/add_delta_timestamp.tz diff --git a/src/bin_client/test/contracts/add_timestamp_delta.tz b/src/bin_client/test/contracts_opcode/add_timestamp_delta.tz similarity index 100% rename from src/bin_client/test/contracts/add_timestamp_delta.tz rename to src/bin_client/test/contracts_opcode/add_timestamp_delta.tz diff --git a/src/bin_client/test/contracts_macros/and.tz b/src/bin_client/test/contracts_opcode/and.tz similarity index 100% rename from src/bin_client/test/contracts_macros/and.tz rename to src/bin_client/test/contracts_opcode/and.tz diff --git a/src/bin_client/test/contracts_macros/balance.tz b/src/bin_client/test/contracts_opcode/balance.tz similarity index 100% rename from src/bin_client/test/contracts_macros/balance.tz rename to src/bin_client/test/contracts_opcode/balance.tz diff --git a/src/bin_client/test/contracts_macros/check_signature.tz b/src/bin_client/test/contracts_opcode/check_signature.tz similarity index 100% rename from src/bin_client/test/contracts_macros/check_signature.tz rename to src/bin_client/test/contracts_opcode/check_signature.tz diff --git a/src/bin_client/test/contracts_macros/concat_hello.tz b/src/bin_client/test/contracts_opcode/concat_hello.tz similarity index 100% rename from src/bin_client/test/contracts_macros/concat_hello.tz rename to src/bin_client/test/contracts_opcode/concat_hello.tz diff --git a/src/bin_client/test/contracts_macros/concat_list.tz b/src/bin_client/test/contracts_opcode/concat_list.tz similarity index 100% rename from src/bin_client/test/contracts_macros/concat_list.tz rename to src/bin_client/test/contracts_opcode/concat_list.tz diff --git a/src/bin_client/test/contracts_macros/contains_all.tz b/src/bin_client/test/contracts_opcode/contains_all.tz similarity index 100% rename from src/bin_client/test/contracts_macros/contains_all.tz rename to src/bin_client/test/contracts_opcode/contains_all.tz diff --git a/src/bin_client/test/contracts_macros/diff_timestamps.tz b/src/bin_client/test/contracts_opcode/diff_timestamps.tz similarity index 100% rename from src/bin_client/test/contracts_macros/diff_timestamps.tz rename to src/bin_client/test/contracts_opcode/diff_timestamps.tz diff --git a/src/bin_client/test/contracts_macros/empty_map.tz b/src/bin_client/test/contracts_opcode/empty_map.tz similarity index 100% rename from src/bin_client/test/contracts_macros/empty_map.tz rename to src/bin_client/test/contracts_opcode/empty_map.tz diff --git a/src/bin_client/test/contracts_macros/exec_concat.tz b/src/bin_client/test/contracts_opcode/exec_concat.tz similarity index 100% rename from src/bin_client/test/contracts_macros/exec_concat.tz rename to src/bin_client/test/contracts_opcode/exec_concat.tz diff --git a/src/bin_client/test/contracts_macros/first.tz b/src/bin_client/test/contracts_opcode/first.tz similarity index 100% rename from src/bin_client/test/contracts_macros/first.tz rename to src/bin_client/test/contracts_opcode/first.tz diff --git a/src/bin_client/test/contracts_macros/get_map_value.tz b/src/bin_client/test/contracts_opcode/get_map_value.tz similarity index 100% rename from src/bin_client/test/contracts_macros/get_map_value.tz rename to src/bin_client/test/contracts_opcode/get_map_value.tz diff --git a/src/bin_client/test/contracts_macros/hash_consistency_checker.tz b/src/bin_client/test/contracts_opcode/hash_consistency_checker.tz similarity index 100% rename from src/bin_client/test/contracts_macros/hash_consistency_checker.tz rename to src/bin_client/test/contracts_opcode/hash_consistency_checker.tz diff --git a/src/bin_client/test/contracts_macros/hash_key.tz b/src/bin_client/test/contracts_opcode/hash_key.tz similarity index 100% rename from src/bin_client/test/contracts_macros/hash_key.tz rename to src/bin_client/test/contracts_opcode/hash_key.tz diff --git a/src/bin_client/test/contracts_macros/hash_string.tz b/src/bin_client/test/contracts_opcode/hash_string.tz similarity index 100% rename from src/bin_client/test/contracts_macros/hash_string.tz rename to src/bin_client/test/contracts_opcode/hash_string.tz diff --git a/src/bin_client/test/contracts_macros/if.tz b/src/bin_client/test/contracts_opcode/if.tz similarity index 100% rename from src/bin_client/test/contracts_macros/if.tz rename to src/bin_client/test/contracts_opcode/if.tz diff --git a/src/bin_client/test/contracts_macros/if_some.tz b/src/bin_client/test/contracts_opcode/if_some.tz similarity index 100% rename from src/bin_client/test/contracts_macros/if_some.tz rename to src/bin_client/test/contracts_opcode/if_some.tz diff --git a/src/bin_client/test/contracts_macros/tez_add_sub.tz b/src/bin_client/test/contracts_opcode/tez_add_sub.tz similarity index 100% rename from src/bin_client/test/contracts_macros/tez_add_sub.tz rename to src/bin_client/test/contracts_opcode/tez_add_sub.tz diff --git a/src/bin_client/test/test_contracts.sh b/src/bin_client/test/test_contracts.sh index 059dad3e7..864742617 100755 --- a/src/bin_client/test/test_contracts.sh +++ b/src/bin_client/test/test_contracts.sh @@ -379,9 +379,9 @@ bake_after $client transfer 500 from bootstrap1 to store_now -arg Unit assert_storage_contains store_now "$($client get timestamp)" # Test timestamp operations -assert_storage $contract_dir/add_timestamp_delta.tz None '(Pair 100 100)' '(Some "1970-01-01T00:03:20Z")' -assert_storage $contract_dir/add_timestamp_delta.tz None '(Pair 100 -100)' '(Some "1970-01-01T00:00:00Z")' -assert_storage $contract_dir/add_timestamp_delta.tz None '(Pair "1970-01-01T00:00:00Z" 0)' '(Some "1970-01-01T00:00:00Z")' +#assert_storage $contract_dir/add_timestamp_delta.tz None '(Pair 100 100)' '(Some "1970-01-01T00:03:20Z")' +#assert_storage $contract_dir/add_timestamp_delta.tz None '(Pair 100 -100)' '(Some "1970-01-01T00:00:00Z")' +#assert_storage $contract_dir/add_timestamp_delta.tz None '(Pair "1970-01-01T00:00:00Z" 0)' '(Some "1970-01-01T00:00:00Z")' #assert_storage $contract_dir/add_delta_timestamp.tz None '(Pair 100 100)' '(Some "1970-01-01T00:03:20Z")' #assert_storage $contract_dir/add_delta_timestamp.tz None '(Pair -100 100)' '(Some "1970-01-01T00:00:00Z")' diff --git a/src/bin_client/test/test_contracts_macros.sh b/src/bin_client/test/test_contracts_macros.sh index b8fb36ed4..acd12001d 100644 --- a/src/bin_client/test/test_contracts_macros.sh +++ b/src/bin_client/test/test_contracts_macros.sh @@ -29,21 +29,78 @@ if [ ! $NO_TYPECHECK ] ; then printf "All contracts are well typed\n\n" fi -assert_storage $contract_macros_dir/add_delta_timestamp.tz None '(Pair 100 100)' '(Some "1970-01-01T00:03:20Z")' -assert_storage $contract_macros_dir/add_delta_timestamp.tz None '(Pair -100 100)' '(Some "1970-01-01T00:00:00Z")' -assert_storage $contract_macros_dir/add_delta_timestamp.tz None '(Pair 0 "1970-01-01T00:00:00Z")' '(Some "1970-01-01T00:00:00Z")' +# ASSERT_CMP +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)' -# Logical and -assert_storage $contract_macros_dir/and.tz None "(Pair False False)" '(Some False)' -assert_storage $contract_macros_dir/and.tz None "(Pair False True)" '(Some False)' -assert_storage $contract_macros_dir/and.tz None "(Pair True False)" '(Some False)' -assert_storage $contract_macros_dir/and.tz None "(Pair True True)" '(Some True)' +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)' -# Get the current balance of the contract -assert_storage $contract_macros_dir/balance.tz '111' Unit '4000000000000' +assert_storage $contract_macros_dir/assert_cmpge.tz Unit '(Pair 0 0)' Unit +assert_storage $contract_macros_dir/assert_cmpge.tz Unit '(Pair 0 -1)' Unit +assert_fails $client run script $contract_macros_dir/assert_cmpge.tz on storage Unit and input '(Pair -1 0)' + +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 -1 0)' +assert_fails $client run script $contract_macros_dir/assert_cmpgt.tz on storage Unit and input '(Pair 0 0)' + +assert_storage $contract_macros_dir/assert_cmple.tz Unit '(Pair 0 0)' Unit +assert_storage $contract_macros_dir/assert_cmple.tz Unit '(Pair -1 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_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 +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 -# Test for big maps +# Test for big map get add + +init_with_transfer $contract_macros_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 big maps member init_with_transfer $contract_macros_dir/big_map_mem.tz $key1\ '(Pair { Elt 1 Unit ; Elt 2 Unit ; Elt 3 Unit } Unit)' \ 100 bootstrap1 @@ -62,35 +119,12 @@ assert_fails $client typecheck data '3' against type \ $client typecheck data '3' against type \ '(int @aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)' -init_with_transfer $contract_macros_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)))' - - # Build list assert_storage $contract_macros_dir/build_list.tz '{}' 0 "{ 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 }" -# Did the given key sign the string? (key is bootstrap1) - -assert_success $client run script $contract_macros_dir/check_signature.tz \ - on storage '(Pair "edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7" "hello")' \ - and input '"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"' - -assert_fails $client run script $contract_macros_dir/check_signature.tz \ - on storage '(Pair "edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7" "abcd")' \ - and input '"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"' - # 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 }' @@ -102,73 +136,6 @@ assert_storage $contract_macros_dir/compare.tz '{}' '(Pair 1000000 2000000)' '{ 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 }' -# Concatenate the string in storage with all strings in the given list -assert_storage $contract_macros_dir/concat_hello.tz '{}' \ - '{ "World!" }' '{ "Hello World!" }' -assert_storage $contract_macros_dir/concat_hello.tz '{}' \ - '{}' '{}' -assert_storage $contract_macros_dir/concat_hello.tz '{}' \ - '{ "test1" ; "test2" }' '{ "Hello test1" ; "Hello test2" }' - -# Concatenate all strings of a list into one string -assert_storage $contract_macros_dir/concat_list.tz '""' '{ "a" ; "b" ; "c" }' '"abc"' -assert_storage $contract_macros_dir/concat_list.tz '""' '{}' '""' -assert_storage $contract_macros_dir/concat_list.tz \ - '""' '{ "Hello" ; " " ; "World" ; "!" }' '"Hello World!"' - -# Contains all elements -- does the second list contain all of the same elements -# as the first one? I'm ignoring element multiplicity -assert_storage $contract_macros_dir/contains_all.tz \ - None '(Pair {} {})' '(Some True)' -assert_storage $contract_macros_dir/contains_all.tz \ - None '(Pair { "a" } { "B" })' '(Some False)' -assert_storage $contract_macros_dir/contains_all.tz \ - None '(Pair { "A" } { "B" })' '(Some False)' -assert_storage $contract_macros_dir/contains_all.tz \ - None '(Pair { "B" } { "B" })' '(Some True)' -assert_storage $contract_macros_dir/contains_all.tz None \ - '(Pair { "B" ; "C" ; "asdf" } { "B" ; "B" ; "asdf" ; "C" })' '(Some True)' -assert_storage $contract_macros_dir/contains_all.tz None \ - '(Pair { "B" ; "B" ; "asdf" ; "C" } { "B" ; "C" ; "asdf" })' '(Some True)' - -# Tests create_account -init_with_transfer $contract_macros_dir/create_account.tz $key2 None 1,000 bootstrap1 -assert_balance create_account "1000 ꜩ" -created_account=\ -`$client transfer 100 from bootstrap1 to create_account -arg '(Left "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx")' \ - | grep 'New contract' \ - | sed -E 's/.*(KT1[a-zA-Z0-9]+).*/\1/' \ - | head -1` -bake -assert_balance $created_account "100 ꜩ" -assert_balance create_account "1000 ꜩ" - -assert_storage $contract_macros_dir/diff_timestamps.tz 111 '(Pair 0 0)' 0 -assert_storage $contract_macros_dir/diff_timestamps.tz 111 '(Pair 0 1)' -1 -assert_storage $contract_macros_dir/diff_timestamps.tz 111 '(Pair 1 0)' 1 -assert_storage $contract_macros_dir/diff_timestamps.tz 111 '(Pair "1970-01-01T00:03:20Z" "1970-01-01T00:00:00Z")' 200 - -# Create an empty map and add a string to it -assert_storage $contract_macros_dir/empty_map.tz '{}' Unit \ - '{ Elt "hello" "world" }' - -# Exec concat contract -assert_storage $contract_macros_dir/exec_concat.tz '"?"' '""' '"_abc"' -assert_storage $contract_macros_dir/exec_concat.tz '"?"' '"test"' '"test_abc"' - -# Test get first element of list -assert_storage $contract_macros_dir/first.tz '111' '{ 1 ; 2 ; 3 ; 4 }' '1' -assert_storage $contract_macros_dir/first.tz '111' '{ 4 }' '4' - -# Get the value stored at the given key in the map -assert_storage $contract_macros_dir/get_map_value.tz '(Pair None { Elt "hello" "hi" })' \ - '"hello"' '(Pair (Some "hi") { Elt "hello" "hi" })' -assert_storage $contract_macros_dir/get_map_value.tz '(Pair None { Elt "hello" "hi" })' \ - '""' '(Pair None { Elt "hello" "hi" })' -assert_storage $contract_macros_dir/get_map_value.tz \ - '(Pair None { Elt "1" "one" ; Elt "2" "two" })' \ - '"1"' '(Pair (Some "one") { Elt "1" "one" ; Elt "2" "two" })' - # Test goldenbook init_with_transfer $contract_macros_dir/guestbook.tz $key1\ '{ Elt "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" None }' \ @@ -178,42 +145,3 @@ 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 ?"' - -# Test hash consistency between Michelson and the CLI -hash_result=`$client hash data '(Pair 22220000000 (Pair "2017-12-13T04:49:00Z" 034))' \ - of type '(pair mutez (pair timestamp int))' | grep Blake2b | sed 's/.*: *//'` - -assert_storage $contract_macros_dir/hash_consistency_checker.tz '0x00' \ - '(Pair 22220000000 (Pair "2017-12-13T04:49:00Z" 034))' "$hash_result" - -assert_storage $contract_macros_dir/hash_consistency_checker.tz '0x00' \ - '(Pair 22220000000 (Pair "2017-12-13T04:49:00+00:00" 34))' "$hash_result" - -# Convert a public key to a public key hash -assert_storage $contract_macros_dir/hash_key.tz None '"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"' \ - '(Some "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx")' -assert_storage $contract_macros_dir/hash_key.tz None '"edpkuJqtDcA2m2muMxViSM47MPsGQzmyjnNTawUPqR8vZTAMcx61ES"' \ - '(Some "tz1XPTDmvT3vVE5Uunngmixm7gj7zmdbPq6k")' - -bake_after $client transfer 1,000 from bootstrap1 to $key1 -bake_after $client transfer 2,000 from bootstrap1 to $key2 - -assert_balance $key1 "1000 ꜩ" -assert_balance $key2 "2000 ꜩ" - -# Hash input string -# Test assumed to be correct -- hash is based on encoding of AST -assert_storage $contract_macros_dir/hash_string.tz '0x00' '"abcdefg"' '0x46fdbcb4ea4eadad5615cdaa17d67f783e01e21149ce2b27de497600b4cd8f4e' -assert_storage $contract_macros_dir/hash_string.tz '0x00' '"12345"' '0xb4c26c20de52a4eaf0d8a340db47ad8cb1e74049570859c9a9a3952b204c772f' - -# IF_SOME -assert_storage $contract_macros_dir/if_some.tz '"?"' '(Some "hello")' '"hello"' -assert_storage $contract_macros_dir/if_some.tz '"?"' 'None' '""' - -# Return True if True branch of if was taken and False otherwise -assert_storage $contract_macros_dir/if.tz None True '(Some True)' -assert_storage $contract_macros_dir/if.tz None False '(Some False)' - -# Test addition and subtraction on tez -assert_storage $contract_macros_dir/tez_add_sub.tz None '(Pair 2000000 1000000)' '(Some (Pair 3000000 1000000))' -assert_storage $contract_macros_dir/tez_add_sub.tz None '(Pair 2310000 1010000)' '(Some (Pair 3320000 1300000))' diff --git a/src/bin_client/test/test_contracts_mini_scenarios.sh b/src/bin_client/test/test_contracts_mini_scenarios.sh index 0061aa4e8..b4288336c 100644 --- a/src/bin_client/test/test_contracts_mini_scenarios.sh +++ b/src/bin_client/test/test_contracts_mini_scenarios.sh @@ -30,6 +30,18 @@ if [ ! $NO_TYPECHECK ] ; then printf "All contracts are well typed\n\n" fi +# Tests create_account +init_with_transfer $contract_scenarios_dir/create_account.tz $key2 None 1,000 bootstrap1 +assert_balance create_account "1000 ꜩ" +created_account=\ +`$client transfer 100 from bootstrap1 to create_account -arg '(Left "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx")' \ + | grep 'New contract' \ + | sed -E 's/.*(KT1[a-zA-Z0-9]+).*/\1/' \ + | head -1` +bake +assert_balance $created_account "100 ꜩ" +assert_balance create_account "1000 ꜩ" + # Creates a contract, transfers data to it and stores the data init_with_transfer $contract_scenarios_dir/create_contract.tz $key2 Unit 1,000 bootstrap1 assert_balance create_contract "1000 ꜩ" diff --git a/src/bin_client/test/test_contracts_opcode.sh b/src/bin_client/test/test_contracts_opcode.sh index 24c410826..48a9139e4 100644 --- a/src/bin_client/test/test_contracts_opcode.sh +++ b/src/bin_client/test/test_contracts_opcode.sh @@ -28,59 +28,127 @@ if [ ! $NO_TYPECHECK ] ; then printf "All contracts are well typed\n\n" fi -# Test ASSERT -assert_storage $contract_op_dir/assert.tz Unit True Unit -assert_fails $client run script $contract_op_dir/assert.tz on storage Unit and input False +# delta timestamp +assert_storage $contract_op_dir/add_delta_timestamp.tz None '(Pair 100 100)' '(Some "1970-01-01T00:03:20Z")' +assert_storage $contract_op_dir/add_delta_timestamp.tz None '(Pair -100 100)' '(Some "1970-01-01T00:00:00Z")' +assert_storage $contract_op_dir/add_delta_timestamp.tz None '(Pair 0 "1970-01-01T00:00:00Z")' '(Some "1970-01-01T00:00:00Z")' -# COMPARE; ASSERT_ +# Test timestamp operations +assert_storage $contract_op_dir/add_timestamp_delta.tz None '(Pair 100 100)' '(Some "1970-01-01T00:03:20Z")' +assert_storage $contract_op_dir/add_timestamp_delta.tz None '(Pair 100 -100)' '(Some "1970-01-01T00:00:00Z")' +assert_storage $contract_op_dir/add_timestamp_delta.tz None '(Pair "1970-01-01T00:00:00Z" 0)' '(Some "1970-01-01T00:00:00Z")' -assert_storage $contract_op_dir/assert_eq.tz Unit '(Pair -1 -1)' Unit -assert_fails $client run script $contract_op_dir/assert_eq.tz on storage Unit and input '(Pair 0 -1)' +# Logical and +assert_storage $contract_op_dir/and.tz None "(Pair False False)" '(Some False)' +assert_storage $contract_op_dir/and.tz None "(Pair False True)" '(Some False)' +assert_storage $contract_op_dir/and.tz None "(Pair True False)" '(Some False)' +assert_storage $contract_op_dir/and.tz None "(Pair True True)" '(Some True)' -assert_storage $contract_op_dir/assert_eq.tz Unit '(Pair -1 -1)' Unit -assert_fails $client run script $contract_op_dir/assert_eq.tz on storage Unit and input '(Pair 0 -1)' +# Get the current balance of the contract +assert_storage $contract_op_dir/balance.tz '111' Unit '4000000000000' -assert_storage $contract_op_dir/assert_neq.tz Unit '(Pair 0 -1)' Unit -assert_fails $client run script $contract_op_dir/assert_neq.tz on storage Unit and input '(Pair -1 -1)' +# Did the given key sign the string? (key is bootstrap1) -assert_storage $contract_op_dir/assert_lt.tz Unit '(Pair -1 0)' Unit -assert_fails $client run script $contract_op_dir/assert_lt.tz on storage Unit and input '(Pair 0 -1)' -assert_fails $client run script $contract_op_dir/assert_lt.tz on storage Unit and input '(Pair 0 0)' +assert_success $client run script $contract_op_dir/check_signature.tz \ + on storage '(Pair "edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7" "hello")' \ + and input '"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"' -assert_storage $contract_op_dir/assert_le.tz Unit '(Pair 0 0)' Unit -assert_storage $contract_op_dir/assert_le.tz Unit '(Pair -1 0)' Unit -assert_fails $client run script $contract_op_dir/assert_le.tz on storage Unit and input '(Pair 0 -1)' +assert_fails $client run script $contract_op_dir/check_signature.tz \ + on storage '(Pair "edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7" "abcd")' \ + and input '"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"' -assert_storage $contract_op_dir/assert_gt.tz Unit '(Pair 0 -1)' Unit -assert_fails $client run script $contract_op_dir/assert_gt.tz on storage Unit and input '(Pair -1 0)' -assert_fails $client run script $contract_op_dir/assert_gt.tz on storage Unit and input '(Pair 0 0)' -assert_storage $contract_op_dir/assert_ge.tz Unit '(Pair 0 0)' Unit -assert_storage $contract_op_dir/assert_ge.tz Unit '(Pair 0 -1)' Unit -assert_fails $client run script $contract_op_dir/assert_ge.tz on storage Unit and input '(Pair -1 0)' +# Concatenate the string in storage with all strings in the given list +assert_storage $contract_op_dir/concat_hello.tz '{}' \ + '{ "World!" }' '{ "Hello World!" }' +assert_storage $contract_op_dir/concat_hello.tz '{}' \ + '{}' '{}' +assert_storage $contract_op_dir/concat_hello.tz '{}' \ + '{ "test1" ; "test2" }' '{ "Hello test1" ; "Hello test2" }' -# ASSERT_CMP -assert_storage $contract_op_dir/assert_cmpeq.tz Unit '(Pair -1 -1)' Unit -assert_fails $client run script $contract_op_dir/assert_cmpeq.tz on storage Unit and input '(Pair 0 -1)' +# Concatenate all strings of a list into one string +assert_storage $contract_op_dir/concat_list.tz '""' '{ "a" ; "b" ; "c" }' '"abc"' +assert_storage $contract_op_dir/concat_list.tz '""' '{}' '""' +assert_storage $contract_op_dir/concat_list.tz \ + '""' '{ "Hello" ; " " ; "World" ; "!" }' '"Hello World!"' -assert_storage $contract_op_dir/assert_cmpeq.tz Unit '(Pair -1 -1)' Unit -assert_fails $client run script $contract_op_dir/assert_cmpeq.tz on storage Unit and input '(Pair 0 -1)' +# Contains all elements -- does the second list contain all of the same elements +# as the first one? I'm ignoring element multiplicity +assert_storage $contract_op_dir/contains_all.tz \ + None '(Pair {} {})' '(Some True)' +assert_storage $contract_op_dir/contains_all.tz \ + None '(Pair { "a" } { "B" })' '(Some False)' +assert_storage $contract_op_dir/contains_all.tz \ + None '(Pair { "A" } { "B" })' '(Some False)' +assert_storage $contract_op_dir/contains_all.tz \ + None '(Pair { "B" } { "B" })' '(Some True)' +assert_storage $contract_op_dir/contains_all.tz None \ + '(Pair { "B" ; "C" ; "asdf" } { "B" ; "B" ; "asdf" ; "C" })' '(Some True)' +assert_storage $contract_op_dir/contains_all.tz None \ + '(Pair { "B" ; "B" ; "asdf" ; "C" } { "B" ; "C" ; "asdf" })' '(Some True)' -assert_storage $contract_op_dir/assert_cmpneq.tz Unit '(Pair 0 -1)' Unit -assert_fails $client run script $contract_op_dir/assert_cmpneq.tz on storage Unit and input '(Pair -1 -1)' +# different timestamp +assert_storage $contract_op_dir/diff_timestamps.tz 111 '(Pair 0 0)' 0 +assert_storage $contract_op_dir/diff_timestamps.tz 111 '(Pair 0 1)' -1 +assert_storage $contract_op_dir/diff_timestamps.tz 111 '(Pair 1 0)' 1 +assert_storage $contract_op_dir/diff_timestamps.tz 111 '(Pair "1970-01-01T00:03:20Z" "1970-01-01T00:00:00Z")' 200 -assert_storage $contract_op_dir/assert_cmplt.tz Unit '(Pair -1 0)' Unit -assert_fails $client run script $contract_op_dir/assert_cmplt.tz on storage Unit and input '(Pair 0 -1)' -assert_fails $client run script $contract_op_dir/assert_cmplt.tz on storage Unit and input '(Pair 0 0)' +# Create an empty map and add a string to it +assert_storage $contract_op_dir/empty_map.tz '{}' Unit \ + '{ Elt "hello" "world" }' -assert_storage $contract_op_dir/assert_cmple.tz Unit '(Pair 0 0)' Unit -assert_storage $contract_op_dir/assert_cmple.tz Unit '(Pair -1 0)' Unit -assert_fails $client run script $contract_op_dir/assert_cmple.tz on storage Unit and input '(Pair 0 -1)' +# Exec concat contract +assert_storage $contract_op_dir/exec_concat.tz '"?"' '""' '"_abc"' +assert_storage $contract_op_dir/exec_concat.tz '"?"' '"test"' '"test_abc"' -assert_storage $contract_op_dir/assert_cmpgt.tz Unit '(Pair 0 -1)' Unit -assert_fails $client run script $contract_op_dir/assert_cmpgt.tz on storage Unit and input '(Pair -1 0)' -assert_fails $client run script $contract_op_dir/assert_cmpgt.tz on storage Unit and input '(Pair 0 0)' +# Test get first element of list +assert_storage $contract_op_dir/first.tz '111' '{ 1 ; 2 ; 3 ; 4 }' '1' +assert_storage $contract_op_dir/first.tz '111' '{ 4 }' '4' -assert_storage $contract_op_dir/assert_cmpge.tz Unit '(Pair 0 0)' Unit -assert_storage $contract_op_dir/assert_cmpge.tz Unit '(Pair 0 -1)' Unit -assert_fails $client run script $contract_op_dir/assert_cmpge.tz on storage Unit and input '(Pair -1 0)' +# Get the value stored at the given key in the map +assert_storage $contract_op_dir/get_map_value.tz '(Pair None { Elt "hello" "hi" })' \ + '"hello"' '(Pair (Some "hi") { Elt "hello" "hi" })' +assert_storage $contract_op_dir/get_map_value.tz '(Pair None { Elt "hello" "hi" })' \ + '""' '(Pair None { Elt "hello" "hi" })' +assert_storage $contract_op_dir/get_map_value.tz \ + '(Pair None { Elt "1" "one" ; Elt "2" "two" })' \ + '"1"' '(Pair (Some "one") { Elt "1" "one" ; Elt "2" "two" })' + +# Test hash consistency between Michelson and the CLI +hash_result=`$client hash data '(Pair 22220000000 (Pair "2017-12-13T04:49:00Z" 034))' \ + of type '(pair mutez (pair timestamp int))' | grep Blake2b | sed 's/.*: *//'` + +assert_storage $contract_op_dir/hash_consistency_checker.tz '0x00' \ + '(Pair 22220000000 (Pair "2017-12-13T04:49:00Z" 034))' "$hash_result" + +assert_storage $contract_op_dir/hash_consistency_checker.tz '0x00' \ + '(Pair 22220000000 (Pair "2017-12-13T04:49:00+00:00" 34))' "$hash_result" + +# Convert a public key to a public key hash +assert_storage $contract_op_dir/hash_key.tz None '"edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"' \ + '(Some "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx")' +assert_storage $contract_op_dir/hash_key.tz None '"edpkuJqtDcA2m2muMxViSM47MPsGQzmyjnNTawUPqR8vZTAMcx61ES"' \ + '(Some "tz1XPTDmvT3vVE5Uunngmixm7gj7zmdbPq6k")' + +bake_after $client transfer 1,000 from bootstrap1 to $key1 +bake_after $client transfer 2,000 from bootstrap1 to $key2 + +assert_balance $key1 "1000 ꜩ" +assert_balance $key2 "2000 ꜩ" + +# Hash input string +# Test assumed to be correct -- hash is based on encoding of AST +assert_storage $contract_op_dir/hash_string.tz '0x00' '"abcdefg"' '0x46fdbcb4ea4eadad5615cdaa17d67f783e01e21149ce2b27de497600b4cd8f4e' +assert_storage $contract_op_dir/hash_string.tz '0x00' '"12345"' '0xb4c26c20de52a4eaf0d8a340db47ad8cb1e74049570859c9a9a3952b204c772f' + +# IF_SOME +assert_storage $contract_op_dir/if_some.tz '"?"' '(Some "hello")' '"hello"' +assert_storage $contract_op_dir/if_some.tz '"?"' 'None' '""' + +# Return True if True branch of if was taken and False otherwise +assert_storage $contract_op_dir/if.tz None True '(Some True)' +assert_storage $contract_op_dir/if.tz None False '(Some False)' + +# Test addition and subtraction on tez +assert_storage $contract_op_dir/tez_add_sub.tz None '(Pair 2000000 1000000)' '(Some (Pair 3000000 1000000))' +assert_storage $contract_op_dir/tez_add_sub.tz None '(Pair 2310000 1010000)' '(Some (Pair 3320000 1300000))'