exchange/src/auditor/test-auditor.sh

33 lines
996 B
Bash
Raw Normal View History

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
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-22 15:43:30 +02:00
jq -h > /dev/null || exit 77
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-22 15:48:35 +02:00
# Run the auditor!
2019-08-22 15:30:02 +02:00
taler-auditor -c test-auditor.conf -m $MASTER_PUB > test-audit.json
2019-08-22 15:48:35 +02:00
# TODO:
# launch bank and run wire-auditor eventually as well!
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... "
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
dropdb $DB
2019-08-22 15:43:30 +02:00
exit $fail