exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

test_bank.sh (2097B)


      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     -S 0ZSX8SH0M30KHX8K3Y1DAMVGDQV82XEF9DG1HC4QMQ3QWYT4AF00 \
     62     -D payto://x-taler-bank/localhost:8899/user?receiver-name=user \
     63     -a TESTKUDOS:4 > /dev/null
     64 echo " OK"
     65 
     66 echo -n "Requesting exchange incoming transaction list ..."
     67 
     68 ./taler-exchange-wire-gateway-client \
     69     -b http://localhost:8899/accounts/exchange/taler-wire-gateway/ \
     70     -i \
     71     | grep TESTKUDOS:4 \
     72     > /dev/null
     73 
     74 echo " OK"
     75 
     76 echo -n "Making wire transfer from exchange..."
     77 
     78 ./taler-exchange-wire-gateway-client \
     79     -b http://localhost:8899/accounts/exchange/taler-wire-gateway/ \
     80     -S 0ZSX8SH0M30KHX8K3Y1DAMVGDQV82XEF9DG1HC4QMQ3QWYT4AF00 \
     81     -C payto://x-taler-bank/localhost:8899/merchant?receiver-name=merchant \
     82     -a TESTKUDOS:2 \
     83     -L DEBUG > /dev/null
     84 echo " OK"
     85 
     86 
     87 echo -n "Requesting exchange's outgoing transaction list..."
     88 
     89 ./taler-exchange-wire-gateway-client \
     90     -b http://localhost:8899/accounts/exchange/taler-wire-gateway/ \
     91     -o \
     92     | grep TESTKUDOS:2 \
     93     > /dev/null
     94 
     95 echo " OK"
     96 
     97 echo "All tests passed"
     98 
     99 exit 0