41 lines
1.1 KiB
Bash
41 lines
1.1 KiB
Bash
#!/bin/bash
|
|
cd "$(dirname "$0")"/..
|
|
|
|
containers=$(docker ps -a | grep -c 'hacker-challenge')
|
|
|
|
if (( "$containers" < 10 )); then
|
|
echo you are supposed to run this after you run ./scripts/testnet.sh
|
|
exit 1
|
|
fi
|
|
|
|
set -e
|
|
|
|
echo -n "Checking if containers connected to each other... "
|
|
for i in {2..12}
|
|
do
|
|
ip="172.17.0.${i}"
|
|
curl -s "${ip}:31372" | grep -e true -e false -c | grep 12 > /dev/null ||
|
|
echo Container at ip ${ip} did not connect to all other containers.
|
|
done
|
|
echo OK!
|
|
|
|
echo -n "Checking if containers can sign data... "
|
|
for i in {2..12}
|
|
do
|
|
ip="172.17.0.${i}"
|
|
random_key=$(curl -s "${ip}:31372" | grep true | tail -1 | awk '{ print $4 }')
|
|
message="ValyDoesNotLikeMyCodeSoHeIsSilentAboutIt"
|
|
status=$(curl -sG \
|
|
-o /dev/null -w "%{http_code}\n" \
|
|
--data-urlencode "pubkey=${random_key}" \
|
|
--data-urlencode "something=${message}" \
|
|
"172.17.0.${i}:31372/sign")
|
|
|
|
if (( "$status" != "200" )); then
|
|
echo Container at ip ${ip} could not sign string with key ${random_key}
|
|
exit 1
|
|
fi
|
|
|
|
done
|
|
echo OK!
|