Tests: split Michelson tests into category opcode

This commit is contained in:
lykimquyen 2018-08-22 14:31:39 +02:00 committed by Benjamin Canou
parent 1b78448ee1
commit e719f401f6
No known key found for this signature in database
GPG Key ID: 73607948459DC5F8
18 changed files with 146 additions and 38 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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"'

View File

@ -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)'

View File

@ -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