#!/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/memory" | grep -e true -e false -c | grep 52 > /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..52} do ip="172.17.0.${i}" random_key=$(curl -s "${ip}:31372/memory" | grep true | tail -1 | awk '{ print $4 }') message="ValyDoesNotLikeMyCodeSoHeIsSilentAboutIt" mkdir -p .tmp status=$(curl -sG \ -o .tmp/output -w "%{http_code}\n" \ --data-urlencode "pubkey=${random_key}" \ --data-urlencode "something=${message}" \ "172.17.0.${i}:31372/memory/sign") if (( "$status" != "200" )); then echo Container at ip ${ip} could not sign string with key ${random_key} echo The status was $status echo The error was $(cat .tmp/output) echo Output of keys on 172.17.0.${i}: curl "172.17.0.${i}:31372/memory" father_of_key=$(curl "172.17.0.${i}:31372/memory" | grep ${random_key} | awk '{ print $2 }') echo Output of keys on ${father_of_key}: curl "${father_of_key}:31372/memory" rm -rf .tmp exit 1 fi done echo OK! rm -rf .tmp