#!/bin/bash set -eu # Exit, with status code "skip" (no 'real' failure) function exit_skip() { echo " SKIP: $1" exit 77 } # Exit, with error message (hard failure) function exit_fail() { echo " FAIL: $1" exit 1 } # Cleanup to run whenever we exit function cleanup() { for n in `jobs -p` do kill $n 2> /dev/null || true done wait } # Install cleanup handler (except for kill -9) trap cleanup EXIT # Script's guidelines: #* uses 'CURRENCY=TESTKUDOS' and uses $CURRENCY for all # currencies in what follows ... #* for databases, use either 'anastasischeck' for Postgres # or an sqlite file created via "mktemp /tmp/test-XXXXXX" # or something like that #* exits with 77 if libeufin is not properly installed/available #* exits with 77 if Postgres with 'anastasischeck' is not properly # installed/available #* starts Nexus (in background) #* starts sandbox (in background) # ~~~~~~~~~ #* creates two IBAN accounts #* stores IBANs of both accounts in shell variables, # call them IBAN_CREDIT and IBAN_DEBIT. #* configures an Anastasis facade for IBAN_CREDIT. #* exports authentication credentials (URL, access token) # for the facade to shell variables # (FACADE_URL, FACADE_AUTH_TOKEN) #* contains a command to do a wire-transfer (pick your amount) # from DEBIT to CREDIT (setup authentication as needed to # trigger the transfer) # # #Make sure 'set -eu' and include some progress indicators, like: # #echo -n "Starting nexus ..." ## DO WORK #echo " DONE" #echo -n "Starting sandbox ..." ## DO WORK #echo " DONE" if ! libeufin-cli --version &> /dev/null; then exit_skip "libeufin-cli not found" fi if ! libeufin-nexus --version &> /dev/null; then exit_skip "libeufin-nexus not found" fi if ! libeufin-sandbox --version &> /dev/null; then exit_skip "libeufin-sandbox not found" fi if ! psql -d anastasischeck -c "\q" &> /dev/null; then exit_skip "Postgresql database 'anastasischeck' not reachable" fi CURRENCY="TESTKUDOS" export LIBEUFIN_NEXUS_DB_CONNECTION="jdbc:sqlite:$(mktemp -u /tmp/nexus-db-XXXXXX.sqlite)" export LIBEUFIN_SANDBOX_DB_CONNECTION="jdbc:sqlite:$(mktemp -u /tmp/sandbox-db-XXXXXX.sqlite)" NEXUS_URL="http://localhost:5001/" SANDBOX_URL="http://localhost:5000/" echo "Starting Nexus .." libeufin-nexus serve &> nexus.log & nexus_pid=$! if ! curl -s --retry 5 --retry-connrefused $NEXUS_URL > /dev/null; then exit_skip "Could not launch Nexus" fi echo "Nexus started." echo "Starting Sandbox .." libeufin-sandbox serve &> sandbox.log & sandbox_pid=$! if ! curl -s --retry 5 --retry-connrefused $SANDBOX_URL > /dev/null; then exit_skip "Could not launch Sandbox" fi echo "Sandbox started." #libeufin-nexus serve &> nexus.log & #nexus_pid=$! #echo "Starting Sandbox .." #libeufin-sandbox serve &> sandbox.log & #sandbox_pid=$! # # #curl -s --retry 5 --retry-connrefused $NEXUS_URL > /dev/null #curl -s --retry 5 --retry-connrefused $SANDBOX_URL > /dev/null