test_bank.sh (2230B)
1 #!/bin/bash 2 # This file is in the public domain. 3 # shellcheck disable=SC2317 4 set -eu 5 6 # Exit, with status code "skip" (no 'real' failure) 7 function exit_skip() { 8 echo "$1" 9 exit 77 10 } 11 12 # Cleanup to run whenever we exit 13 function cleanup() 14 { 15 for n in $(jobs -p) 16 do 17 kill "$n" 2> /dev/null || true 18 done 19 wait 20 } 21 22 # Install cleanup handler (except for kill -9) 23 trap cleanup EXIT 24 25 echo -n "Launching bank..." 26 27 taler-fakebank-run \ 28 -c test_bank.conf \ 29 -L DEBUG &> bank.log & 30 31 # Wait for bank to be available (usually the slowest) 32 for n in $(seq 1 50) 33 do 34 echo -n "." 35 sleep 0.2 36 OK=0 37 # bank 38 wget \ 39 --tries=1 \ 40 --timeout=1 \ 41 http://localhost:8899/ \ 42 -o /dev/null \ 43 -O /dev/null \ 44 >/dev/null \ 45 || continue 46 OK=1 47 break 48 done 49 50 if [ 1 != "$OK" ] 51 then 52 exit_skip "Failed to launch services (bank)" 53 fi 54 55 echo "OK" 56 57 echo -n "Making wire transfer to exchange ..." 58 59 taler-exchange-wire-gateway-client \ 60 -b http://localhost:8899/accounts/exchange/taler-wire-gateway/ \ 61 -u notneeded \ 62 -p noauth \ 63 -S 0ZSX8SH0M30KHX8K3Y1DAMVGDQV82XEF9DG1HC4QMQ3QWYT4AF00 \ 64 -D payto://x-taler-bank/localhost:8899/user?receiver-name=user \ 65 -a TESTKUDOS:4 > /dev/null 66 echo " OK" 67 68 echo -n "Requesting exchange incoming transaction list ..." 69 70 taler-exchange-wire-gateway-client \ 71 -b http://localhost:8899/accounts/exchange/taler-wire-gateway/ \ 72 -u notneeded \ 73 -p noauth \ 74 -i \ 75 | grep TESTKUDOS:4 \ 76 > /dev/null 77 78 echo " OK" 79 80 echo -n "Making wire transfer from exchange..." 81 82 taler-exchange-wire-gateway-client \ 83 -b http://localhost:8899/accounts/exchange/taler-wire-gateway/ \ 84 -u notneeded \ 85 -p noauth \ 86 -S 0ZSX8SH0M30KHX8K3Y1DAMVGDQV82XEF9DG1HC4QMQ3QWYT4AF00 \ 87 -C payto://x-taler-bank/localhost:8899/merchant?receiver-name=merchant \ 88 -a TESTKUDOS:2 \ 89 -L INFO > /dev/null 90 echo " OK" 91 92 93 echo -n "Requesting exchange's outgoing transaction list..." 94 95 taler-exchange-wire-gateway-client \ 96 -b http://localhost:8899/accounts/exchange/taler-wire-gateway/ \ 97 -u notneeded \ 98 -p noauth \ 99 -o \ 100 | grep TESTKUDOS:2 \ 101 > /dev/null 102 103 echo " OK" 104 105 echo "All tests passed" 106 107 exit 0