Test: faster testsuite

No need to wait 1 second between blocks!
This commit is contained in:
Grégoire Henry 2018-04-21 17:16:01 +02:00
parent a3a33c4814
commit 0fe8975817
12 changed files with 71 additions and 118 deletions

View File

@ -19,9 +19,7 @@ $client rpc call '/blocks/head/raw_context/delegates/?depth=2' | assert '{ "cont
$client rpc call '/blocks/head/raw_context/non-existent?depth=-1' | assert 'No service found at this URL' $client rpc call '/blocks/head/raw_context/non-existent?depth=-1' | assert 'No service found at this URL'
$client rpc call '/blocks/head/raw_context/non-existent?depth=0' | assert 'No service found at this URL' $client rpc call '/blocks/head/raw_context/non-existent?depth=0' | assert 'No service found at this URL'
bake
$client bake for bootstrap1 -max-priority 512
sleep 1
key1=foo key1=foo
key2=bar key2=bar
@ -55,73 +53,43 @@ $client get balance for $key2 | assert "2,000 ꜩ"
# Should fail # Should fail
# $client transfer 999.95 from $key2 to $key1 # $client transfer 999.95 from $key2 to $key1
# wait for the delay between two block bake
sleep 1
$client bake for bootstrap1 -max-priority 512
$client remember program noop file:contracts/noop.tz $client remember program noop file:contracts/noop.tz
$client typecheck program noop $client typecheck program file:contracts/noop.tz
$client originate contract noop \ bake_after $client originate contract noop \
for $key1 transferring 1,000 from bootstrap1 \ for $key1 transferring 1,000 from bootstrap1 \
running noop running file:contracts/noop.tz
sleep 1
$client bake for bootstrap1 -max-priority 512 bake_after $client transfer 10 from bootstrap1 to noop -arg "Unit"
$client transfer 10 from bootstrap1 to noop -arg "Unit"
sleep 1
$client bake for bootstrap1 -max-priority 512
$client originate contract hardlimit \ bake_after $client originate contract hardlimit \
for $key1 transferring 1,000 from bootstrap1 \ for $key1 transferring 1,000 from bootstrap1 \
running file:contracts/hardlimit.tz -init "3" running file:contracts/hardlimit.tz -init "3"
sleep 1 bake_after $client transfer 10 from bootstrap1 to hardlimit -arg "Unit"
$client bake for bootstrap1 -max-priority 512 bake_after $client transfer 10 from bootstrap1 to hardlimit -arg "Unit"
$client transfer 10 from bootstrap1 to hardlimit -arg "Unit"
sleep 1
$client bake for bootstrap1 -max-priority 512
$client transfer 10 from bootstrap1 to hardlimit -arg "Unit"
# $client transfer 10 from bootstrap1 to hardlimit -arg "unit" # should fail
sleep 1
$client bake for bootstrap1 -max-priority 512
$client originate account free_account for $key1 \ bake_after $client originate account free_account for $key1 \
transferring 1,000 from bootstrap1 -delegatable transferring 1,000 from bootstrap1 -delegatable
sleep 1
$client bake for bootstrap1 -max-priority 512
$client get delegate for free_account $client get delegate for free_account
sleep 1
$client bake for bootstrap1 -max-priority 512 bake_after $client register key $key2 as delegate
$client register key $key2 as delegate bake_after $client set delegate for free_account to $key2
sleep 1
$client bake for bootstrap1 -max-priority 512
$client set delegate for free_account to $key2
sleep 1
$client bake for bootstrap1 -max-priority 512
$client get delegate for free_account $client get delegate for free_account
$client get balance for bootstrap5 | assert "4,000,000 ꜩ" $client get balance for bootstrap5 | assert "4,000,000 ꜩ"
$client transfer 400,000 from bootstrap5 to bootstrap1 -fee 0 bake_after $client transfer 400,000 from bootstrap5 to bootstrap1 -fee 0
sleep 1 bake_after $client transfer 400,000 from bootstrap1 to bootstrap5 -fee 0
$client bake for bootstrap1 -max-priority 512
$client transfer 400,000 from bootstrap1 to bootstrap5 -fee 0
sleep 1
$client bake for bootstrap1 -max-priority 512
$client get balance for bootstrap5 | assert "4,000,000 ꜩ" $client get balance for bootstrap5 | assert "4,000,000 ꜩ"
sleep 1
bake_after $client activate account $key4 with king_commitment.json --no-confirmation
$client activate account $key4 with king_commitment.json --no-confirmation bake_after $client activate account $key5 with queen_commitment.json --no-confirmation
$client activate account $key5 with queen_commitment.json --no-confirmation
$client bake for bootstrap1 -max-priority 512
sleep 1
$client get balance for $key4 | assert "23,932,454.669,343 ꜩ" $client get balance for $key4 | assert "23,932,454.669,343 ꜩ"
$client get balance for $key5 | assert "72,954,577.464,032 ꜩ" $client get balance for $key5 | assert "72,954,577.464,032 ꜩ"
$client transfer 10 from $key4 to $key5 bake_after $client transfer 10 from $key4 to $key5
echo echo
echo End of test echo End of test

View File

@ -9,8 +9,7 @@ source $test_dir/test_lib.inc.sh "$@"
start_node 1 start_node 1
activate_alpha activate_alpha
sleep 2 bake
$client bake for bootstrap5 -max-priority 512
key1=foo key1=foo
key2=bar key2=bar
@ -386,16 +385,12 @@ init_with_transfer $contract_dir/create_account.tz $key2 \
"\"$(get_contract_addr test_transfer_account1)\"" 1,000 bootstrap1 "\"$(get_contract_addr test_transfer_account1)\"" 1,000 bootstrap1
$client transfer 100 from bootstrap1 to create_account \ $client transfer 100 from bootstrap1 to create_account \
-arg '"tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"' | assert_in_output "New contract" -arg '"tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"' | assert_in_output "New contract"
$client bake for bootstrap1 -max-priority 512 bake
sleep 1
# 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 \ init_with_transfer $contract_dir/create_contract.tz $key2 \
"\"$(get_contract_addr test_transfer_account1)\"" 1,000 bootstrap1 "\"$(get_contract_addr test_transfer_account1)\"" 1,000 bootstrap1
$client transfer 0 from bootstrap1 to create_contract -arg '"tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"' bake_after $client transfer 0 from bootstrap1 to create_contract -arg '"tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"'
$client bake for bootstrap1 -max-priority 512
sleep 1
assert_storage_contains create_contract '"abcdefg"' assert_storage_contains create_contract '"abcdefg"'
# Test DEFAULT_ACCOUNT # Test DEFAULT_ACCOUNT
@ -433,52 +428,28 @@ assert_output $contract_dir/hash_consistency_checker.tz Unit \
init_with_transfer $contract_dir/big_map_mem.tz $key1\ init_with_transfer $contract_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
$client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 0 False)' bake_after $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 0 False)'
$client bake for bootstrap1 -max-priority 512
sleep 1
assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 0 True)' assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 0 True)'
$client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 1 True)' bake_after $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 1 True)'
$client bake for bootstrap1 -max-priority 512
sleep 1
assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 1 False)' assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 1 False)'
$client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 2 True)' bake_after $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 2 True)'
$client bake for bootstrap1 -max-priority 512
sleep 1
assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 2 False)' assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 2 False)'
$client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 3 True)' bake_after $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 3 True)'
$client bake for bootstrap1 -max-priority 512
sleep 1
assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 3 False)' assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 3 False)'
$client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 4 False)' bake_after $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 4 False)'
$client bake for bootstrap1 -max-priority 512
sleep 1
assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 4 True)' assert_fails $client transfer 1 from bootstrap1 to big_map_mem -arg '(Pair 4 True)'
init_with_transfer $contract_dir/big_map_get_add.tz $key1\ init_with_transfer $contract_dir/big_map_get_add.tz $key1\
'(Pair { Elt 0 1 ; Elt 1 2 ; Elt 2 3 } Unit)' \ '(Pair { Elt 0 1 ; Elt 1 2 ; Elt 2 3 } Unit)' \
100 bootstrap1 100 bootstrap1
$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 (Some 2)) (Pair 200 (Some 2)))'
$client bake for bootstrap1 -max-priority 512 bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 200 None) (Pair 200 None))'
sleep 1 bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 200 None) (Pair 300 None))'
$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 1 None) (Pair 200 None))'
$client bake for bootstrap1 -max-priority 512 bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 1 (Some 2)) (Pair 0 (Some 1)))'
sleep 1 bake_after $client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 400 (Some 1232)) (Pair 400 (Some 1232)))'
$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 401 (Some 0)) (Pair 400 (Some 1232)))'
$client bake for bootstrap1 -max-priority 512
sleep 1
$client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 1 None) (Pair 200 None))'
$client bake for bootstrap1 -max-priority 512
sleep 1
$client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 1 (Some 2)) (Pair 0 (Some 1)))'
$client bake for bootstrap1 -max-priority 512
sleep 1
$client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 400 (Some 1232)) (Pair 400 (Some 1232)))'
$client bake for bootstrap1 -max-priority 512
sleep 1
$client transfer 1 from bootstrap1 to big_map_get_add -arg '(Pair (Pair 401 (Some 0)) (Pair 400 (Some 1232)))'
$client bake for bootstrap1 -max-priority 512
sleep 1
printf "\nEnd of test\n" printf "\nEnd of test\n"

View File

@ -23,7 +23,7 @@ dictator_secret="edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6"
protocol_version="Ps1ZDZdgRP4PFDkzmFpiYtE7gJHioavCMxC96i9zJsK6URwSXSJ" protocol_version="Ps1ZDZdgRP4PFDkzmFpiYtE7gJHioavCMxC96i9zJsK6URwSXSJ"
protocol_short="Ps1ZDZdgRP4PFD" protocol_short="Ps1ZDZdgRP4PFD"
$client bake for bootstrap1 -max-priority 512 bake
$client list understood protocols $client list understood protocols

View File

@ -23,7 +23,7 @@ dictator_secret="edsk31vznjHSSpGExDMHYASz45VZqXN4DPxvsa4hAyY8dHM28cZzp6"
protocol_version="Ps1ZDZdgRP4PFDkzmFpiYtE7gJHioavCMxC96i9zJsK6URwSXSJ" protocol_version="Ps1ZDZdgRP4PFDkzmFpiYtE7gJHioavCMxC96i9zJsK6URwSXSJ"
protocol_short="Ps1ZDZdgRP4PFD" protocol_short="Ps1ZDZdgRP4PFD"
$client bake for bootstrap1 -max-priority 512 bake
$client list understood protocols $client list understood protocols

View File

@ -140,6 +140,15 @@ init_contract_from_file () {
$client remember program "${NAME}" "file:${FILE}" $client remember program "${NAME}" "file:${FILE}"
} }
bake () {
$client bake for bootstrap1 --max-priority 512 --minimal-timestamp
}
bake_after () {
"$@"
bake
}
init_with_transfer () { init_with_transfer () {
local FILE="$1" local FILE="$1"
local NAME=$(contract_name_of_file "${FILE}") local NAME=$(contract_name_of_file "${FILE}")
@ -151,15 +160,7 @@ init_with_transfer () {
$client originate contract ${NAME} \ $client originate contract ${NAME} \
for ${KEY} transferring "${TRANSFER_AMT}" \ for ${KEY} transferring "${TRANSFER_AMT}" \
from ${TRANSFER_SRC} running "${FILE}" -init "${INITIAL_STORAGE}" from ${TRANSFER_SRC} running "${FILE}" -init "${INITIAL_STORAGE}"
$client bake for bootstrap1 -max-priority 512 bake
sleep 1
}
bake_after () {
"$@"
$client bake for bootstrap1 -max-priority 512
sleep 1
} }
# Takes a grep regexp and fails with an error message if command does not include # Takes a grep regexp and fails with an error message if command does not include

View File

@ -72,16 +72,16 @@ retry() {
retry 2 15 assert_protocol "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK" retry 2 15 assert_protocol "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"
$client1 bake for bootstrap1 -max-priority 512 $client1 bake for bootstrap1 --max-priority 512 --minimal-timestamp
retry 2 15 assert_propagation_level 2 retry 2 15 assert_propagation_level 2
$client2 bake for bootstrap2 -max-priority 512 $client2 bake for bootstrap2 --max-priority 512 --minimal-timestamp
retry 2 15 assert_propagation_level 3 retry 2 15 assert_propagation_level 3
$client3 bake for bootstrap3 -max-priority 512 $client3 bake for bootstrap3 --max-priority 512 --minimal-timestamp
retry 2 15 assert_propagation_level 4 retry 2 15 assert_propagation_level 4
$client4 bake for bootstrap4 -max-priority 512 $client4 bake for bootstrap4 --max-priority 512 --minimal-timestamp
retry 2 15 assert_propagation_level 5 retry 2 15 assert_propagation_level 5
endorse_hash=$($client3 endorse for bootstrap3 | extract_operation_hash) endorse_hash=$($client3 endorse for bootstrap3 | extract_operation_hash)
@ -100,7 +100,7 @@ assert_contains_operation() {
done done
} }
$client4 bake for bootstrap4 -max-priority 512 $client4 bake for bootstrap4 --max-priority 512 --minimal-timestamp
retry 2 15 assert_contains_operation $endorse_hash retry 2 15 assert_contains_operation $endorse_hash
retry 2 15 assert_contains_operation $transfer_hash retry 2 15 assert_contains_operation $transfer_hash

View File

@ -221,7 +221,9 @@ activate_alpha() {
activate protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK \ activate protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK \
with fitness 1 \ with fitness 1 \
and key dictator \ and key dictator \
and parameters "${parameters_file}" and parameters "${parameters_file}" \
--timestamp $(date +%FT%TZ --utc --date="1 hour ago")
} }
usage() { usage() {
@ -272,7 +274,7 @@ main () {
cat <<EOF cat <<EOF
if type tezos-client-reset >/dev/null 2>&1 ; then tezos-client-reset; fi ; if type tezos-client-reset >/dev/null 2>&1 ; then tezos-client-reset; fi ;
PATH="$client_dir/bin:\$PATH" ; export PATH ; PATH="$client_dir/bin:\$PATH" ; export PATH ;
alias tezos-activate-alpha="$client -block genesis activate protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK with fitness 1 and key dictator and parameters $parameters_file" ; alias tezos-activate-alpha="$client -block genesis activate protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK with fitness 1 and key dictator and parameters $parameters_file --timestamp $(date +%FT%TZ --utc --date="1 hour ago")" ;
alias tezos-client-reset="rm -rf \"$client_dir\"; unalias tezos-activate-alpha tezos-client-reset" ; alias tezos-client-reset="rm -rf \"$client_dir\"; unalias tezos-activate-alpha tezos-client-reset" ;
alias tezos-autocomplete="if [ \$ZSH_NAME ] ; then autoload bashcompinit ; bashcompinit ; fi ; source \"$bin_dir/bash-completion.sh\"" ; alias tezos-autocomplete="if [ \$ZSH_NAME ] ; then autoload bashcompinit ; bashcompinit ; fi ; source \"$bin_dir/bash-completion.sh\"" ;
trap tezos-client-reset EXIT ; trap tezos-client-reset EXIT ;

View File

@ -37,14 +37,15 @@ let commands () =
(fun max_priority delegate cctxt -> (fun max_priority delegate cctxt ->
endorse_block cctxt ?max_priority delegate) ; endorse_block cctxt ?max_priority delegate) ;
command ~group ~desc: "Forge and inject block using the delegate rights." command ~group ~desc: "Forge and inject block using the delegate rights."
(args3 max_priority_arg force_switch free_baking_switch) (args4 max_priority_arg force_switch
free_baking_switch minimal_timestamp_switch)
(prefixes [ "bake"; "for" ] (prefixes [ "bake"; "for" ]
@@ Client_keys.Public_key_hash.source_param @@ Client_keys.Public_key_hash.source_param
~name:"baker" ~desc: "name of the delegate owning the baking right" ~name:"baker" ~desc: "name of the delegate owning the baking right"
@@ stop) @@ stop)
(fun (max_priority, force, free_baking) delegate cctxt -> (fun (max_priority, force, free_baking, minimal_timestamp) delegate cctxt ->
bake_block cctxt cctxt#block bake_block cctxt cctxt#block
~force ?max_priority ~free_baking delegate) ; ~force ?max_priority ~minimal_timestamp ~free_baking delegate) ;
command ~group ~desc: "Forge and inject a seed-nonce revelation operation." command ~group ~desc: "Forge and inject a seed-nonce revelation operation."
no_options no_options
(prefixes [ "reveal"; "nonce"; "for" ] (prefixes [ "reveal"; "nonce"; "for" ]

View File

@ -11,7 +11,8 @@ open Proto_alpha
open Alpha_context open Alpha_context
let bake_block (cctxt : #Proto_alpha.full) block let bake_block (cctxt : #Proto_alpha.full) block
?force ?max_priority ?(free_baking=false) ?src_sk delegate = ?force ?max_priority ?(free_baking=false) ?(minimal_timestamp=false)
?src_sk delegate =
begin begin
match src_sk with match src_sk with
| None -> | None ->
@ -28,7 +29,7 @@ let bake_block (cctxt : #Proto_alpha.full) block
else else
None, None in None, None in
Client_baking_forge.forge_block cctxt Client_baking_forge.forge_block cctxt
~timestamp:(Time.now ()) ?timestamp:(if minimal_timestamp then None else Some (Time.now ()))
?force ?force
?seed_nonce_hash ~src_sk block ?seed_nonce_hash ~src_sk block
~priority:(`Auto (delegate, max_priority, free_baking)) () >>=? fun block_hash -> ~priority:(`Auto (delegate, max_priority, free_baking)) () >>=? fun block_hash ->

View File

@ -17,6 +17,7 @@ val bake_block:
?force:bool -> ?force:bool ->
?max_priority: int -> ?max_priority: int ->
?free_baking: bool -> ?free_baking: bool ->
?minimal_timestamp: bool ->
?src_sk:Client_keys.sk_locator -> ?src_sk:Client_keys.sk_locator ->
public_key_hash -> public_key_hash ->
unit tzresult Lwt.t unit tzresult Lwt.t

View File

@ -106,6 +106,13 @@ let force_switch =
\ current head." \ current head."
() ()
let minimal_timestamp_switch =
switch
~long:"minimal-timestamp"
~doc:"Use the minimal timestamp instead of the current date \
as timestamp of the baked block."
()
let delegatable_switch = let delegatable_switch =
switch switch
~long:"delegatable" ~long:"delegatable"

View File

@ -23,6 +23,7 @@ val spendable_switch: (bool, Proto_alpha.full) Clic.arg
val max_priority_arg: (int option, Proto_alpha.full) Clic.arg val max_priority_arg: (int option, Proto_alpha.full) Clic.arg
val free_baking_switch: (bool, Proto_alpha.full) Clic.arg val free_baking_switch: (bool, Proto_alpha.full) Clic.arg
val force_switch: (bool, Proto_alpha.full) Clic.arg val force_switch: (bool, Proto_alpha.full) Clic.arg
val minimal_timestamp_switch: (bool, Proto_alpha.full) Clic.arg
val endorsement_delay_arg: (int, Proto_alpha.full) Clic.arg val endorsement_delay_arg: (int, Proto_alpha.full) Clic.arg
val no_print_source_flag: (bool, Proto_alpha.full) Clic.arg val no_print_source_flag: (bool, Proto_alpha.full) Clic.arg