2019-08-22 15:30:02 +02:00
|
|
|
#!/bin/bash
|
2019-08-22 15:43:30 +02:00
|
|
|
# Setup database which was generated from a perfectly normal
|
|
|
|
# exchange-wallet interaction and run the auditor against it.
|
|
|
|
#
|
|
|
|
# Check that the auditor report is as expected.
|
|
|
|
#
|
|
|
|
# Requires 'jq' tool and Postgres superuser rights!
|
2019-08-22 15:30:02 +02:00
|
|
|
set -eu
|
2019-08-23 15:10:10 +02:00
|
|
|
|
2019-08-23 15:17:54 +02:00
|
|
|
# test required commands exist
|
|
|
|
echo "Testing for jq"
|
|
|
|
jq -h > /dev/null || exit 77
|
|
|
|
echo "Testing for taler-bank-manage"
|
|
|
|
taler-bank-manage -h >/dev/null || exit 77
|
|
|
|
echo "Testing for pdflatex"
|
|
|
|
which pdflatex > /dev/null || exit 77
|
|
|
|
|
2019-08-23 15:10:10 +02:00
|
|
|
echo "Database setup"
|
2019-08-22 15:30:02 +02:00
|
|
|
DB=taler-auditor-test
|
2019-08-22 15:43:30 +02:00
|
|
|
dropdb $DB 2> /dev/null || true
|
2019-08-22 15:30:02 +02:00
|
|
|
createdb -T template0 $DB || exit 77
|
2019-08-23 15:17:54 +02:00
|
|
|
|
2019-08-22 15:48:35 +02:00
|
|
|
# Import pre-generated database, -q(ietly) using single (-1) transaction
|
2019-08-22 15:43:30 +02:00
|
|
|
psql $DB -q -1 -f ../benchmark/auditor-basedb.sql > /dev/null
|
2019-08-22 15:30:02 +02:00
|
|
|
MASTER_PUB=`cat ../benchmark/auditor-basedb.mpub`
|
|
|
|
|
2019-08-23 15:10:10 +02:00
|
|
|
# Launch bank
|
|
|
|
echo "Launching bank"
|
|
|
|
taler-bank-manage -c test-auditor.conf serve-http 2>/dev/null >/dev/null &
|
2019-08-23 15:21:26 +02:00
|
|
|
|
2019-08-23 15:10:10 +02:00
|
|
|
|
2019-08-22 15:48:35 +02:00
|
|
|
# Run the auditor!
|
2019-08-23 15:10:10 +02:00
|
|
|
echo "Running audit(s)"
|
2019-08-22 15:30:02 +02:00
|
|
|
taler-auditor -c test-auditor.conf -m $MASTER_PUB > test-audit.json
|
2019-08-23 15:10:10 +02:00
|
|
|
taler-wire-auditor -c test-auditor.conf -m $MASTER_PUB > test-wire-audit.json
|
|
|
|
|
|
|
|
echo "Shutting down services"
|
|
|
|
kill `jobs -p`
|
2019-08-22 15:30:02 +02:00
|
|
|
|
2019-08-22 15:43:30 +02:00
|
|
|
|
2019-08-23 15:10:10 +02:00
|
|
|
echo "TeXing"
|
|
|
|
../../contrib/render.py test-audit.json test-wire-audit.json < ../../contrib/auditor-report.tex.j2 > test-report.tex
|
2019-08-23 15:17:54 +02:00
|
|
|
|
2019-08-23 15:10:10 +02:00
|
|
|
pdflatex test-report.tex >/dev/null
|
|
|
|
pdflatex test-report.tex >/dev/null
|
|
|
|
|
|
|
|
echo "Checking output"
|
2019-08-22 15:43:30 +02:00
|
|
|
fail=0
|
|
|
|
# if an emergency was detected, that is a bug and we should fail
|
|
|
|
echo -n "Test for emergencies... "
|
2019-08-23 13:26:51 +02:00
|
|
|
jq -e .emergencies[0] < test-audit.json > /dev/null && (echo Failed; fail=1) || echo OK
|
2019-08-22 15:43:30 +02:00
|
|
|
|
|
|
|
# TODO: Add more checks to ensure test-audit.json matches expectations
|
2019-08-22 15:30:02 +02:00
|
|
|
|
2019-08-23 15:10:10 +02:00
|
|
|
|
|
|
|
echo "Cleanup"
|
2019-08-22 15:30:02 +02:00
|
|
|
dropdb $DB
|
|
|
|
|
2019-08-22 15:43:30 +02:00
|
|
|
exit $fail
|