2017-08-09 18:09:41 +04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2017-08-28 20:34:36 +04:00
|
|
|
set -e
|
|
|
|
|
|
|
|
test_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)")"
|
2017-12-06 22:51:57 +04:00
|
|
|
source $test_dir/lib/test_lib.inc.sh "$@"
|
2017-08-28 20:34:36 +04:00
|
|
|
|
2017-11-11 06:34:12 +04:00
|
|
|
expected_connections=4
|
2017-08-28 20:34:36 +04:00
|
|
|
max_peer_id=8
|
|
|
|
for i in $(seq 1 $max_peer_id); do
|
|
|
|
echo
|
|
|
|
echo "## Starting node $i."
|
|
|
|
echo
|
|
|
|
start_node $i
|
|
|
|
echo
|
|
|
|
done
|
|
|
|
|
2017-11-11 06:34:12 +04:00
|
|
|
## waiting for the node to establish connections
|
|
|
|
|
2017-08-28 20:34:36 +04:00
|
|
|
for client in "${client_instances[@]}"; do
|
|
|
|
echo
|
|
|
|
echo "### $client network stat"
|
|
|
|
echo
|
2017-11-11 06:34:12 +04:00
|
|
|
$client bootstrapped
|
2017-08-28 20:34:36 +04:00
|
|
|
$client network stat
|
|
|
|
echo
|
|
|
|
done
|
|
|
|
|
|
|
|
activate_alpha
|
2017-08-09 18:09:41 +04:00
|
|
|
|
|
|
|
assert_propagation_level() {
|
|
|
|
level=$1
|
|
|
|
printf "\n\nAsserting all nodes have reached level %s\n" "$level"
|
2017-08-28 20:34:36 +04:00
|
|
|
for client in "${client_instances[@]}"; do
|
2017-09-28 19:40:17 +04:00
|
|
|
( $client rpc call /blocks/head/proto/context/level \
|
|
|
|
| assert_in_output "\"level\": $level" ) \
|
|
|
|
|| exit 2
|
2017-08-28 20:34:36 +04:00
|
|
|
done
|
2017-08-09 18:09:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-11 06:34:12 +04:00
|
|
|
assert_protocol() {
|
|
|
|
proto=$1
|
|
|
|
printf "\n\nAsserting protocol propagation\n"
|
|
|
|
for client in "${client_instances[@]}"; do
|
|
|
|
( $client rpc call /blocks/head/protocol | assert_in_output "$proto" ) \
|
|
|
|
|| exit 2
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2017-08-09 18:09:41 +04:00
|
|
|
|
|
|
|
printf "\n\n"
|
|
|
|
|
2017-09-28 19:40:17 +04:00
|
|
|
retry() {
|
|
|
|
local timeout=$1
|
|
|
|
local attempts=$2
|
|
|
|
shift 2
|
|
|
|
sleep $timeout
|
|
|
|
while ! ( "$@" ) ; do
|
|
|
|
echo
|
|
|
|
echo "Will retry after $timeout seconds..."
|
|
|
|
echo
|
|
|
|
sleep $timeout
|
|
|
|
attempts=$(($attempts-1))
|
|
|
|
if [ "$attempts" -eq 0 ] ; then
|
|
|
|
echo
|
|
|
|
echo "Failed after too many retries" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2017-11-11 06:34:12 +04:00
|
|
|
retry 2 15 assert_protocol "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"
|
|
|
|
|
2017-11-20 06:37:06 +04:00
|
|
|
$client1 bake for bootstrap1 -max-priority 512
|
2017-09-28 19:40:17 +04:00
|
|
|
retry 2 15 assert_propagation_level 2
|
2017-08-09 18:09:41 +04:00
|
|
|
|
2017-11-20 06:37:06 +04:00
|
|
|
$client2 bake for bootstrap2 -max-priority 512
|
2017-09-28 19:40:17 +04:00
|
|
|
retry 2 15 assert_propagation_level 3
|
2017-08-09 18:09:41 +04:00
|
|
|
|
2017-11-20 06:37:06 +04:00
|
|
|
$client3 bake for bootstrap3 -max-priority 512
|
2017-09-28 19:40:17 +04:00
|
|
|
retry 2 15 assert_propagation_level 4
|
2017-08-09 18:09:41 +04:00
|
|
|
|
2017-11-20 06:37:06 +04:00
|
|
|
$client4 bake for bootstrap4 -max-priority 512
|
2017-09-28 19:40:17 +04:00
|
|
|
retry 2 15 assert_propagation_level 5
|
2017-08-09 18:09:41 +04:00
|
|
|
|
2017-08-28 20:34:36 +04:00
|
|
|
endorse_hash=$($client3 endorse for bootstrap3 | extract_operation_hash)
|
|
|
|
transfer_hash=$($client4 transfer 500 from bootstrap1 to bootstrap3 | extract_operation_hash)
|
2017-08-09 18:09:41 +04:00
|
|
|
|
2017-11-11 06:34:12 +04:00
|
|
|
# wait for the propagation of operations
|
|
|
|
sleep 2
|
2017-08-09 18:09:41 +04:00
|
|
|
|
|
|
|
assert_contains_operation() {
|
|
|
|
hash="$1"
|
|
|
|
printf "Asserting operations list contains '$hash'\n"
|
2017-08-28 20:34:36 +04:00
|
|
|
for client in "${client_instances[@]}"; do
|
2017-09-28 19:40:17 +04:00
|
|
|
( $client rpc call /blocks/head/operations with {} \
|
|
|
|
| assert_in_output $hash ) \
|
|
|
|
|| exit 2
|
2017-08-28 20:34:36 +04:00
|
|
|
done
|
2017-08-09 18:09:41 +04:00
|
|
|
}
|
|
|
|
|
2017-11-20 06:37:06 +04:00
|
|
|
$client4 bake for bootstrap4 -max-priority 512
|
2017-09-28 19:40:17 +04:00
|
|
|
retry 2 15 assert_contains_operation $endorse_hash
|
2017-11-11 06:34:12 +04:00
|
|
|
retry 2 15 assert_contains_operation $transfer_hash
|
2017-08-09 18:09:41 +04:00
|
|
|
|
2017-08-28 20:34:36 +04:00
|
|
|
echo
|
|
|
|
echo End of test
|
|
|
|
echo
|
|
|
|
|
|
|
|
show_logs="no"
|