Tests: split Michelson tests into category mini_scenarios
This commit is contained in:
parent
a37a1f49f7
commit
8d09fffbab
@ -158,6 +158,11 @@ test:contracts_macros.sh:
|
|||||||
script:
|
script:
|
||||||
- dune build @src/bin_client/runtest_contracts_macros.sh
|
- dune build @src/bin_client/runtest_contracts_macros.sh
|
||||||
|
|
||||||
|
test:contracts_mini_scenarios.sh:
|
||||||
|
<<: *test_definition
|
||||||
|
script:
|
||||||
|
- dune build @src/bin_client/runtest_contracts_mini_scenarios.sh
|
||||||
|
|
||||||
test:multinode.sh:
|
test:multinode.sh:
|
||||||
<<: *test_definition
|
<<: *test_definition
|
||||||
script:
|
script:
|
||||||
|
@ -61,6 +61,21 @@
|
|||||||
%{bin:tezos-client}
|
%{bin:tezos-client}
|
||||||
%{bin:tezos-admin-client})))
|
%{bin:tezos-admin-client})))
|
||||||
|
|
||||||
|
(alias
|
||||||
|
(name runtest_contracts_mini_scenarios.sh)
|
||||||
|
(deps sandbox.json
|
||||||
|
test_lib.inc.sh
|
||||||
|
(glob_files contracts_mini_scenarios/*))
|
||||||
|
(locks /tcp-port/18731
|
||||||
|
/tcp-port/19731)
|
||||||
|
(action
|
||||||
|
(run bash %{dep:test_contracts_mini_scenarios.sh}
|
||||||
|
%{bin:tezos-sandboxed-node.sh}
|
||||||
|
%{bin:tezos-node}
|
||||||
|
%{bin:tezos-init-sandboxed-client.sh}
|
||||||
|
%{bin:tezos-client}
|
||||||
|
%{bin:tezos-admin-client})))
|
||||||
|
|
||||||
(alias
|
(alias
|
||||||
(name runtest_multinode.sh)
|
(name runtest_multinode.sh)
|
||||||
(deps sandbox.json
|
(deps sandbox.json
|
||||||
@ -131,6 +146,7 @@
|
|||||||
(alias runtest_contracts.sh)
|
(alias runtest_contracts.sh)
|
||||||
(alias runtest_contracts_opcode.sh)
|
(alias runtest_contracts_opcode.sh)
|
||||||
(alias runtest_contracts_macros.sh)
|
(alias runtest_contracts_macros.sh)
|
||||||
|
(alias runtest_contracts_mini_scenarios.sh)
|
||||||
(alias runtest_multinode.sh)
|
(alias runtest_multinode.sh)
|
||||||
(alias runtest_injection.sh)
|
(alias runtest_injection.sh)
|
||||||
(alias runtest_tls.sh)
|
(alias runtest_tls.sh)
|
||||||
|
@ -427,26 +427,26 @@ assert_fails $client transfer 0 from bootstrap1 to replay
|
|||||||
#assert_balance create_account "1000 ꜩ"
|
#assert_balance create_account "1000 ꜩ"
|
||||||
|
|
||||||
# Creates a contract, transfers data to it and stores the data
|
# Creates a contract, transfers data to it and stores the data
|
||||||
init_with_transfer $contract_dir/create_contract.tz $key2 Unit 1,000 bootstrap1
|
#init_with_transfer $contract_dir/create_contract.tz $key2 Unit 1,000 bootstrap1
|
||||||
assert_balance create_contract "1000 ꜩ"
|
#assert_balance create_contract "1000 ꜩ"
|
||||||
created_contract=\
|
#created_contract=\
|
||||||
`$client transfer 0 from bootstrap1 to create_contract -arg '(Left "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx")' \
|
#`$client transfer 0 from bootstrap1 to create_contract -arg '(Left "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx")' \
|
||||||
| grep 'New contract' \
|
#| grep 'New contract' \
|
||||||
| sed -E 's/.*(KT1[a-zA-Z0-9]+).*/\1/' \
|
#| sed -E 's/.*(KT1[a-zA-Z0-9]+).*/\1/' \
|
||||||
| head -1`
|
#| head -1`
|
||||||
bake
|
#bake
|
||||||
assert_storage_contains $created_contract '"abcdefg"'
|
#assert_storage_contains $created_contract '"abcdefg"'
|
||||||
assert_balance $created_contract "100 ꜩ"
|
#assert_balance $created_contract "100 ꜩ"
|
||||||
assert_balance create_contract "900 ꜩ"
|
#assert_balance create_contract "900 ꜩ"
|
||||||
|
|
||||||
# Test IMPLICIT_ACCOUNT
|
# Test IMPLICIT_ACCOUNT
|
||||||
init_with_transfer $contract_dir/default_account.tz $key1 \
|
#init_with_transfer $contract_dir/default_account.tz $key1 \
|
||||||
Unit 1,000 bootstrap1
|
# Unit 1,000 bootstrap1
|
||||||
bake_after $client transfer 0 from bootstrap1 to default_account -arg "\"$BOOTSTRAP4_IDENTITY\""
|
#bake_after $client transfer 0 from bootstrap1 to default_account -arg "\"$BOOTSTRAP4_IDENTITY\""
|
||||||
assert_balance $BOOTSTRAP4_IDENTITY "4000100 ꜩ"
|
#assert_balance $BOOTSTRAP4_IDENTITY "4000100 ꜩ"
|
||||||
account=tz1SuakBpFdG9b4twyfrSMqZzruxhpMeSrE5
|
#account=tz1SuakBpFdG9b4twyfrSMqZzruxhpMeSrE5
|
||||||
bake_after $client transfer 0 from bootstrap1 to default_account -arg "\"$account\""
|
#bake_after $client transfer 0 from bootstrap1 to default_account -arg "\"$account\""
|
||||||
assert_balance $account "100 ꜩ"
|
#assert_balance $account "100 ꜩ"
|
||||||
|
|
||||||
# Test SELF
|
# Test SELF
|
||||||
init_with_transfer $contract_dir/self.tz $key1 \
|
init_with_transfer $contract_dir/self.tz $key1 \
|
||||||
@ -504,24 +504,24 @@ bake_after $client transfer 0 from bootstrap1 to split_bytes -arg '0xddeeff'
|
|||||||
assert_storage_contains split_bytes '{ 0xaa ; 0xbb ; 0xcc ; 0xdd ; 0xee ; 0xff }'
|
assert_storage_contains split_bytes '{ 0xaa ; 0xbb ; 0xcc ; 0xdd ; 0xee ; 0xff }'
|
||||||
|
|
||||||
# Test SET_DELEGATE
|
# Test SET_DELEGATE
|
||||||
b2='tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN'
|
#b2='tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN'
|
||||||
b3='tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU'
|
#b3='tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU'
|
||||||
b4='tz1b7tUupMgCNw2cCLpKTkSD1NZzB5TkP2sv'
|
#b4='tz1b7tUupMgCNw2cCLpKTkSD1NZzB5TkP2sv'
|
||||||
b5='tz1ddb9NMYHZi5UzPdzTZMYQQZoMub195zgv'
|
#b5='tz1ddb9NMYHZi5UzPdzTZMYQQZoMub195zgv'
|
||||||
init_with_transfer $contract_dir/vote_for_delegate.tz bootstrap1 \
|
#init_with_transfer $contract_dir/vote_for_delegate.tz bootstrap1 \
|
||||||
"(Pair (Pair \"$b3\" None) (Pair \"$b4\" None))" 1,000 bootstrap1
|
# "(Pair (Pair \"$b3\" None) (Pair \"$b4\" None))" 1,000 bootstrap1
|
||||||
$client get delegate for vote_for_delegate | assert_in_output none
|
#$client get delegate for vote_for_delegate | assert_in_output none
|
||||||
|
|
||||||
assert_fails $client transfer 0 from bootstrap1 to vote_for_delegate -arg None
|
#assert_fails $client transfer 0 from bootstrap1 to vote_for_delegate -arg None
|
||||||
assert_fails $client transfer 0 from bootstrap2 to vote_for_delegate -arg None
|
#assert_fails $client transfer 0 from bootstrap2 to vote_for_delegate -arg None
|
||||||
bake_after $client transfer 0 from bootstrap3 to vote_for_delegate -arg "(Some \"$b5\")"
|
#bake_after $client transfer 0 from bootstrap3 to vote_for_delegate -arg "(Some \"$b5\")"
|
||||||
assert_storage_contains vote_for_delegate "\"$b5\""
|
#assert_storage_contains vote_for_delegate "\"$b5\""
|
||||||
$client get delegate for vote_for_delegate | assert_in_output none
|
#$client get delegate for vote_for_delegate | assert_in_output none
|
||||||
bake_after $client transfer 0 from bootstrap4 to vote_for_delegate -arg "(Some \"$b2\")"
|
#bake_after $client transfer 0 from bootstrap4 to vote_for_delegate -arg "(Some \"$b2\")"
|
||||||
assert_storage_contains vote_for_delegate "\"$b2\""
|
#assert_storage_contains vote_for_delegate "\"$b2\""
|
||||||
$client get delegate for vote_for_delegate | assert_in_output none
|
#$client get delegate for vote_for_delegate | assert_in_output none
|
||||||
bake_after $client transfer 0 from bootstrap4 to vote_for_delegate -arg "(Some \"$b5\")"
|
#bake_after $client transfer 0 from bootstrap4 to vote_for_delegate -arg "(Some \"$b5\")"
|
||||||
$client get delegate for vote_for_delegate | assert_in_output "$b5"
|
#$client get delegate for vote_for_delegate | assert_in_output "$b5"
|
||||||
|
|
||||||
# Test sets and map literals
|
# Test sets and map literals
|
||||||
assert_fails $client typecheck data '{ Elt 0 1 ; Elt 0 1 }' against type '(map nat nat)'
|
assert_fails $client typecheck data '{ Elt 0 1 ; Elt 0 1 }' against type '(map nat nat)'
|
||||||
|
73
src/bin_client/test/test_contracts_mini_scenarios.sh
Normal file
73
src/bin_client/test/test_contracts_mini_scenarios.sh
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
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_scenarios_dir/*.tz`; do
|
||||||
|
printf "[Typechecking %s]\n" "$contract";
|
||||||
|
${client} typecheck script "$contract";
|
||||||
|
done
|
||||||
|
printf "All contracts are well typed\n\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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 ꜩ"
|
||||||
|
created_contract=\
|
||||||
|
`$client transfer 0 from bootstrap1 to create_contract -arg '(Left "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx")' \
|
||||||
|
| grep 'New contract' \
|
||||||
|
| sed -E 's/.*(KT1[a-zA-Z0-9]+).*/\1/' \
|
||||||
|
| head -1`
|
||||||
|
bake
|
||||||
|
assert_storage_contains $created_contract '"abcdefg"'
|
||||||
|
assert_balance $created_contract "100 ꜩ"
|
||||||
|
assert_balance create_contract "900 ꜩ"
|
||||||
|
|
||||||
|
# Test IMPLICIT_ACCOUNT
|
||||||
|
init_with_transfer $contract_scenarios_dir/default_account.tz $key1 \
|
||||||
|
Unit 1,000 bootstrap1
|
||||||
|
bake_after $client transfer 0 from bootstrap1 to default_account -arg "\"$BOOTSTRAP4_IDENTITY\""
|
||||||
|
assert_balance $BOOTSTRAP4_IDENTITY "4000100 ꜩ"
|
||||||
|
account=tz1SuakBpFdG9b4twyfrSMqZzruxhpMeSrE5
|
||||||
|
bake_after $client transfer 0 from bootstrap1 to default_account -arg "\"$account\""
|
||||||
|
assert_balance $account "100 ꜩ"
|
||||||
|
|
||||||
|
# Test SET_DELEGATE
|
||||||
|
b2='tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN'
|
||||||
|
b3='tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU'
|
||||||
|
b4='tz1b7tUupMgCNw2cCLpKTkSD1NZzB5TkP2sv'
|
||||||
|
b5='tz1ddb9NMYHZi5UzPdzTZMYQQZoMub195zgv'
|
||||||
|
init_with_transfer $contract_scenarios_dir/vote_for_delegate.tz bootstrap1 \
|
||||||
|
"(Pair (Pair \"$b3\" None) (Pair \"$b4\" None))" 1,000 bootstrap1
|
||||||
|
$client get delegate for vote_for_delegate | assert_in_output none
|
||||||
|
|
||||||
|
assert_fails $client transfer 0 from bootstrap1 to vote_for_delegate -arg None
|
||||||
|
assert_fails $client transfer 0 from bootstrap2 to vote_for_delegate -arg None
|
||||||
|
bake_after $client transfer 0 from bootstrap3 to vote_for_delegate -arg "(Some \"$b5\")"
|
||||||
|
assert_storage_contains vote_for_delegate "\"$b5\""
|
||||||
|
$client get delegate for vote_for_delegate | assert_in_output none
|
||||||
|
bake_after $client transfer 0 from bootstrap4 to vote_for_delegate -arg "(Some \"$b2\")"
|
||||||
|
assert_storage_contains vote_for_delegate "\"$b2\""
|
||||||
|
$client get delegate for vote_for_delegate | assert_in_output none
|
||||||
|
bake_after $client transfer 0 from bootstrap4 to vote_for_delegate -arg "(Some \"$b5\")"
|
||||||
|
$client get delegate for vote_for_delegate | assert_in_output "$b5"
|
@ -19,6 +19,7 @@ local_compiler="${6:-$test_dir/../../../_build/default/src/lib_protocol_compiler
|
|||||||
contract_dir="contracts"
|
contract_dir="contracts"
|
||||||
contract_op_dir="contracts_opcode"
|
contract_op_dir="contracts_opcode"
|
||||||
contract_macros_dir="contracts_macros"
|
contract_macros_dir="contracts_macros"
|
||||||
|
contract_scenarios_dir="contracts_mini_scenarios"
|
||||||
|
|
||||||
source $tezos_sandboxed_node
|
source $tezos_sandboxed_node
|
||||||
source $tezos_init_sandboxed_client
|
source $tezos_init_sandboxed_client
|
||||||
|
Loading…
Reference in New Issue
Block a user