exchange/src/auditor/test-auditor.sh

29 lines
838 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
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`
taler-auditor -c test-auditor.conf -m $MASTER_PUB > test-audit.json
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 < test-audit.json > /dev/null && (echo Failed; fail=1) || echo OK
# 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