diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d83fee4c4..f6207a137 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -148,6 +148,11 @@ test:contracts.sh: script: - dune build @src/bin_client/runtest_contracts.sh +test:contracts_opcode.sh: + <<: *test_definition + script: + - dune build @src/bin_client/runtest_contracts_opcode.sh + test:multinode.sh: <<: *test_definition script: diff --git a/src/bin_client/test/contracts/assert.tz b/src/bin_client/test/contracts_opcode/assert.tz similarity index 100% rename from src/bin_client/test/contracts/assert.tz rename to src/bin_client/test/contracts_opcode/assert.tz diff --git a/src/bin_client/test/contracts/assert_cmpeq.tz b/src/bin_client/test/contracts_opcode/assert_cmpeq.tz similarity index 100% rename from src/bin_client/test/contracts/assert_cmpeq.tz rename to src/bin_client/test/contracts_opcode/assert_cmpeq.tz diff --git a/src/bin_client/test/contracts/assert_cmpge.tz b/src/bin_client/test/contracts_opcode/assert_cmpge.tz similarity index 100% rename from src/bin_client/test/contracts/assert_cmpge.tz rename to src/bin_client/test/contracts_opcode/assert_cmpge.tz diff --git a/src/bin_client/test/contracts/assert_cmpgt.tz b/src/bin_client/test/contracts_opcode/assert_cmpgt.tz similarity index 100% rename from src/bin_client/test/contracts/assert_cmpgt.tz rename to src/bin_client/test/contracts_opcode/assert_cmpgt.tz diff --git a/src/bin_client/test/contracts/assert_cmple.tz b/src/bin_client/test/contracts_opcode/assert_cmple.tz similarity index 100% rename from src/bin_client/test/contracts/assert_cmple.tz rename to src/bin_client/test/contracts_opcode/assert_cmple.tz diff --git a/src/bin_client/test/contracts/assert_cmplt.tz b/src/bin_client/test/contracts_opcode/assert_cmplt.tz similarity index 100% rename from src/bin_client/test/contracts/assert_cmplt.tz rename to src/bin_client/test/contracts_opcode/assert_cmplt.tz diff --git a/src/bin_client/test/contracts/assert_cmpneq.tz b/src/bin_client/test/contracts_opcode/assert_cmpneq.tz similarity index 100% rename from src/bin_client/test/contracts/assert_cmpneq.tz rename to src/bin_client/test/contracts_opcode/assert_cmpneq.tz diff --git a/src/bin_client/test/contracts/assert_eq.tz b/src/bin_client/test/contracts_opcode/assert_eq.tz similarity index 100% rename from src/bin_client/test/contracts/assert_eq.tz rename to src/bin_client/test/contracts_opcode/assert_eq.tz diff --git a/src/bin_client/test/contracts/assert_ge.tz b/src/bin_client/test/contracts_opcode/assert_ge.tz similarity index 100% rename from src/bin_client/test/contracts/assert_ge.tz rename to src/bin_client/test/contracts_opcode/assert_ge.tz diff --git a/src/bin_client/test/contracts/assert_gt.tz b/src/bin_client/test/contracts_opcode/assert_gt.tz similarity index 100% rename from src/bin_client/test/contracts/assert_gt.tz rename to src/bin_client/test/contracts_opcode/assert_gt.tz diff --git a/src/bin_client/test/contracts/assert_le.tz b/src/bin_client/test/contracts_opcode/assert_le.tz similarity index 100% rename from src/bin_client/test/contracts/assert_le.tz rename to src/bin_client/test/contracts_opcode/assert_le.tz diff --git a/src/bin_client/test/contracts/assert_lt.tz b/src/bin_client/test/contracts_opcode/assert_lt.tz similarity index 100% rename from src/bin_client/test/contracts/assert_lt.tz rename to src/bin_client/test/contracts_opcode/assert_lt.tz diff --git a/src/bin_client/test/contracts/assert_neq.tz b/src/bin_client/test/contracts_opcode/assert_neq.tz similarity index 100% rename from src/bin_client/test/contracts/assert_neq.tz rename to src/bin_client/test/contracts_opcode/assert_neq.tz diff --git a/src/bin_client/test/dune b/src/bin_client/test/dune index ead9cce07..3e7ef9849 100644 --- a/src/bin_client/test/dune +++ b/src/bin_client/test/dune @@ -31,6 +31,21 @@ %{bin:tezos-client} %{bin:tezos-admin-client}))) +(alias + (name runtest_contracts_opcode.sh) + (deps sandbox.json + test_lib.inc.sh + (glob_files contracts_opcode/*)) + (locks /tcp-port/18731 + /tcp-port/19731) + (action + (run bash %{dep:test_contracts_opcode.sh} + %{bin:tezos-sandboxed-node.sh} + %{bin:tezos-node} + %{bin:tezos-init-sandboxed-client.sh} + %{bin:tezos-client} + %{bin:tezos-admin-client}))) + (alias (name runtest_multinode.sh) (deps sandbox.json @@ -99,6 +114,7 @@ (name runtest) (deps (alias runtest_basic.sh) (alias runtest_contracts.sh) + (alias runtest_contracts_opcode.sh) (alias runtest_multinode.sh) (alias runtest_injection.sh) (alias runtest_tls.sh) diff --git a/src/bin_client/test/test_contracts.sh b/src/bin_client/test/test_contracts.sh index 3b1a82789..0bb4d7bf4 100755 --- a/src/bin_client/test/test_contracts.sh +++ b/src/bin_client/test/test_contracts.sh @@ -258,60 +258,60 @@ assert_storage $contract_dir/hash_string.tz '0x00' '"abcdefg"' '0x46fdbcb4ea4ead assert_storage $contract_dir/hash_string.tz '0x00' '"12345"' '0xb4c26c20de52a4eaf0d8a340db47ad8cb1e74049570859c9a9a3952b204c772f' # 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 +#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_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_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_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_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_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_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_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_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_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_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_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)' +#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)' # IF_SOME assert_storage $contract_dir/if_some.tz '"?"' '(Some "hello")' '"hello"' diff --git a/src/bin_client/test/test_contracts_opcode.sh b/src/bin_client/test/test_contracts_opcode.sh new file mode 100644 index 000000000..24c410826 --- /dev/null +++ b/src/bin_client/test/test_contracts_opcode.sh @@ -0,0 +1,86 @@ +set -e +set -o pipefail + +test_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)")" +source $test_dir/test_lib.inc.sh "$@" + +start_node 1 +activate_alpha + +$client -w none config update + +bake + +key1=foo +key2=bar + +$client gen keys $key1 +$client gen keys $key2 + +printf "\n\n" + +# Assert all contracts typecheck +if [ ! $NO_TYPECHECK ] ; then + for contract in `ls $contract_op_dir/*.tz`; do + printf "[Typechecking %s]\n" "$contract"; + ${client} typecheck script "$contract"; + done + 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 + +# COMPARE; ASSERT_ + +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)' + +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)' + +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)' + +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_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_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)' + +# 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)' + +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)' + +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)' + +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)' + +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)' + +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)' + +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)' diff --git a/src/bin_client/test/test_lib.inc.sh b/src/bin_client/test/test_lib.inc.sh index 2db469132..9d43de802 100755 --- a/src/bin_client/test/test_lib.inc.sh +++ b/src/bin_client/test/test_lib.inc.sh @@ -17,6 +17,7 @@ local_admin_client="${5:-$test_dir/../../../_build/default/src/bin_client/main_a local_compiler="${6:-$test_dir/../../../_build/default/src/lib_protocol_compiler/main_native.exe}" contract_dir="contracts" +contract_op_dir="contracts_opcode" source $tezos_sandboxed_node source $tezos_init_sandboxed_client