more comprehensive test-auditor.sh, including generate-auditor-basedb now
This commit is contained in:
parent
bde4c742de
commit
0d5a3d7b6f
@ -1,7 +1,7 @@
|
|||||||
# This file is in the public domain.
|
# This file is in the public domain.
|
||||||
#
|
#
|
||||||
[auditor]
|
[auditor]
|
||||||
# Which database backend do we use for the auditor?
|
# Which database backend do we use for the auditor?
|
||||||
DB = postgres
|
DB = postgres
|
||||||
|
|
||||||
# Option specifying which amount is considered 'tiny'
|
# Option specifying which amount is considered 'tiny'
|
||||||
@ -26,4 +26,4 @@ UNIXPATH = ${TALER_RUNTIME_DIR}/exchange.http
|
|||||||
UNIXPATH_MODE = 660
|
UNIXPATH_MODE = 660
|
||||||
|
|
||||||
# HTTP port the auditor listens to
|
# HTTP port the auditor listens to
|
||||||
PORT = 8082
|
PORT = 8083
|
||||||
|
@ -41,7 +41,7 @@ cp generate-auditor-basedb-template.conf $CONF
|
|||||||
echo -n "Testing for taler-bank-manage"
|
echo -n "Testing for taler-bank-manage"
|
||||||
taler-bank-manage -h >/dev/null </dev/null || exit_skip " MISSING"
|
taler-bank-manage -h >/dev/null </dev/null || exit_skip " MISSING"
|
||||||
echo " FOUND"
|
echo " FOUND"
|
||||||
echo "Testing for taler-wallet-cli"
|
echo -n "Testing for taler-wallet-cli"
|
||||||
taler-wallet-cli -h >/dev/null </dev/null || exit_skip " MISSING"
|
taler-wallet-cli -h >/dev/null </dev/null || exit_skip " MISSING"
|
||||||
echo " FOUND"
|
echo " FOUND"
|
||||||
|
|
||||||
@ -94,12 +94,32 @@ taler-bank-manage -c $CONF serve-http &
|
|||||||
taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log &
|
taler-exchange-httpd -c $CONF 2> taler-exchange-httpd.log &
|
||||||
taler-merchant-httpd -c $CONF 2> taler-merchant-httpd.log &
|
taler-merchant-httpd -c $CONF 2> taler-merchant-httpd.log &
|
||||||
taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log &
|
taler-exchange-wirewatch -c $CONF 2> taler-exchange-wirewatch.log &
|
||||||
|
taler-auditor-httpd -c $CONF 2> taler-auditor-httpd.log &
|
||||||
|
|
||||||
|
# Wait for all services to be available
|
||||||
|
for n in `seq 1 20`
|
||||||
|
do
|
||||||
|
echo -n "."
|
||||||
|
sleep 0.1
|
||||||
|
OK=0
|
||||||
|
# exchange
|
||||||
|
wget http://localhost:8081/ -o /dev/null -O /dev/null >/dev/null || continue
|
||||||
|
# merchant
|
||||||
|
wget http://localhost:9966/ -o /dev/null -O /dev/null >/dev/null || continue
|
||||||
|
# bank
|
||||||
|
wget http://localhost:8082/ -o /dev/null -O /dev/null >/dev/null || continue
|
||||||
|
# Auditor
|
||||||
|
wget http://localhost:8083/ -o /dev/null -O /dev/null >/dev/null || continue
|
||||||
|
OK=1
|
||||||
|
break
|
||||||
|
done
|
||||||
|
|
||||||
# FIXME: also launch taler-auditor-httpd!
|
if [ 1 != $OK ]
|
||||||
|
then
|
||||||
# FIXME: interactive test here instead of waiting!
|
kill `jobs -p`
|
||||||
sleep 10
|
exit_skip "Failed to launch services"
|
||||||
|
fi
|
||||||
|
echo " DONE"
|
||||||
|
|
||||||
# run wallet CLI
|
# run wallet CLI
|
||||||
echo "Running wallet"
|
echo "Running wallet"
|
||||||
@ -123,3 +143,9 @@ dropdb $TARGET_DB
|
|||||||
rm -f e2a.dat a2e.dat
|
rm -f e2a.dat a2e.dat
|
||||||
rm -rf $DATA_DIR || true
|
rm -rf $DATA_DIR || true
|
||||||
rm $CONF
|
rm $CONF
|
||||||
|
|
||||||
|
echo "====================================="
|
||||||
|
echo " Finished generation of $BASEDB"
|
||||||
|
echo "====================================="
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
@ -802,16 +802,6 @@ function test_14() {
|
|||||||
|
|
||||||
echo "===========14: wire-fee disagreement==========="
|
echo "===========14: wire-fee disagreement==========="
|
||||||
|
|
||||||
|
|
||||||
# Wire fees are only checked/generated once there are
|
|
||||||
# actual outgoing wire transfers, so we need to run the
|
|
||||||
# aggregator here.
|
|
||||||
pre_audit aggregator
|
|
||||||
echo "UPDATE wire_fee SET wire_fee_frac=100;" | psql -Aqt $DB
|
|
||||||
audit_only
|
|
||||||
post_audit
|
|
||||||
|
|
||||||
|
|
||||||
# Check wire transfer lag reported (no aggregator!)
|
# Check wire transfer lag reported (no aggregator!)
|
||||||
# NOTE: This test is EXPECTED to fail for ~1h after
|
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||||
# re-generating the test database as we do not
|
# re-generating the test database as we do not
|
||||||
@ -819,6 +809,15 @@ post_audit
|
|||||||
# taler-wire-auditor.c)
|
# taler-wire-auditor.c)
|
||||||
if [ $DATABASE_AGE -gt 3600 ]
|
if [ $DATABASE_AGE -gt 3600 ]
|
||||||
then
|
then
|
||||||
|
|
||||||
|
# Wire fees are only checked/generated once there are
|
||||||
|
# actual outgoing wire transfers, so we need to run the
|
||||||
|
# aggregator here.
|
||||||
|
pre_audit aggregator
|
||||||
|
echo "UPDATE wire_fee SET wire_fee_frac=100;" | psql -Aqt $DB
|
||||||
|
audit_only
|
||||||
|
post_audit
|
||||||
|
|
||||||
echo -n "Testing inconsistency detection... "
|
echo -n "Testing inconsistency detection... "
|
||||||
TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
|
TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
|
||||||
if test "x$TABLE" != "xwire-fee"
|
if test "x$TABLE" != "xwire-fee"
|
||||||
@ -831,14 +830,15 @@ then
|
|||||||
exit_fail "Reported diagnostic wrong: $DIAG"
|
exit_fail "Reported diagnostic wrong: $DIAG"
|
||||||
fi
|
fi
|
||||||
echo PASS
|
echo PASS
|
||||||
else
|
|
||||||
echo "Inconsistency detection: SKIP (database too new)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# cannot easily undo aggregator, hence full reload
|
# cannot easily undo aggregator, hence full reload
|
||||||
echo -n "Reloading database ..."
|
echo -n "Reloading database ..."
|
||||||
full_reload
|
full_reload
|
||||||
echo "DONE"
|
echo "DONE"
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Test skipped (database too new)"
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -847,21 +847,24 @@ echo "DONE"
|
|||||||
# Test where h_wire in the deposit table is wrong
|
# Test where h_wire in the deposit table is wrong
|
||||||
function test_15() {
|
function test_15() {
|
||||||
echo "===========15: deposit wire hash wrong================="
|
echo "===========15: deposit wire hash wrong================="
|
||||||
# Modify h_wire hash, so it is inconsistent with 'wire'
|
|
||||||
echo "UPDATE deposits SET h_wire='\x973e52d193a357940be9ef2939c19b0575ee1101f52188c3c01d9005b7d755c397e92624f09cfa709104b3b65605fe5130c90d7e1b7ee30f8fc570f39c16b853' WHERE deposit_serial_id=1" | psql -Aqt $DB
|
|
||||||
|
|
||||||
# The auditor checks h_wire consistency only for
|
|
||||||
# coins where the wire transfer has happened, hence
|
|
||||||
# run aggregator first to get this test to work.
|
|
||||||
run_audit aggregator
|
|
||||||
|
|
||||||
# Check wire transfer lag reported (no aggregator!)
|
# Check wire transfer lag reported (no aggregator!)
|
||||||
|
|
||||||
# NOTE: This test is EXPECTED to fail for ~1h after
|
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||||
# re-generating the test database as we do not
|
# re-generating the test database as we do not
|
||||||
# report lag of less than 1h (see GRACE_PERIOD in
|
# report lag of less than 1h (see GRACE_PERIOD in
|
||||||
# taler-wire-auditor.c)
|
# taler-wire-auditor.c)
|
||||||
if [ $DATABASE_AGE -gt 3600 ]
|
if [ $DATABASE_AGE -gt 3600 ]
|
||||||
then
|
then
|
||||||
|
|
||||||
|
# Modify h_wire hash, so it is inconsistent with 'wire'
|
||||||
|
echo "UPDATE deposits SET h_wire='\x973e52d193a357940be9ef2939c19b0575ee1101f52188c3c01d9005b7d755c397e92624f09cfa709104b3b65605fe5130c90d7e1b7ee30f8fc570f39c16b853' WHERE deposit_serial_id=1" | psql -Aqt $DB
|
||||||
|
|
||||||
|
# The auditor checks h_wire consistency only for
|
||||||
|
# coins where the wire transfer has happened, hence
|
||||||
|
# run aggregator first to get this test to work.
|
||||||
|
run_audit aggregator
|
||||||
|
|
||||||
echo -n "Testing inconsistency detection... "
|
echo -n "Testing inconsistency detection... "
|
||||||
TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
|
TABLE=`jq -r .row_inconsistencies[0].table < test-audit.json`
|
||||||
if test "x$TABLE" != "xaggregation" -a "x$TABLE" != "xdeposits"
|
if test "x$TABLE" != "xaggregation" -a "x$TABLE" != "xdeposits"
|
||||||
@ -869,14 +872,15 @@ then
|
|||||||
exit_fail "Reported table wrong: $TABLE"
|
exit_fail "Reported table wrong: $TABLE"
|
||||||
fi
|
fi
|
||||||
echo PASS
|
echo PASS
|
||||||
else
|
|
||||||
echo "Inconsistency detection: SKIP (database too new)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# cannot easily undo aggregator, hence full reload
|
# cannot easily undo aggregator, hence full reload
|
||||||
echo -n "Reloading database ..."
|
echo -n "Reloading database ..."
|
||||||
full_reload
|
full_reload
|
||||||
echo "DONE"
|
echo "DONE"
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Test skipped (database too new)"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -884,20 +888,6 @@ echo "DONE"
|
|||||||
function test_16() {
|
function test_16() {
|
||||||
echo "===========16: incorrect wire_out amount================="
|
echo "===========16: incorrect wire_out amount================="
|
||||||
|
|
||||||
# First, we need to run the aggregator so we even
|
|
||||||
# have a wire_out to modify.
|
|
||||||
pre_audit aggregator
|
|
||||||
|
|
||||||
# Modify wire amount, such that it is inconsistent with 'aggregation'
|
|
||||||
# (exchange account is #2, so the logic below should select the outgoing
|
|
||||||
# wire transfer):
|
|
||||||
OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 ORDER BY id LIMIT 1;" | psql $DB -Aqt`
|
|
||||||
OLD_AMOUNT=`echo "SELECT amount FROM app_banktransaction WHERE id='${OLD_ID}';" | psql $DB -Aqt`
|
|
||||||
NEW_AMOUNT="TESTKUDOS:50"
|
|
||||||
echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE id='${OLD_ID}';" | psql -Aqt $DB
|
|
||||||
|
|
||||||
audit_only
|
|
||||||
|
|
||||||
# Check wire transfer lag reported (no aggregator!)
|
# Check wire transfer lag reported (no aggregator!)
|
||||||
# NOTE: This test is EXPECTED to fail for ~1h after
|
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||||
# re-generating the test database as we do not
|
# re-generating the test database as we do not
|
||||||
@ -905,6 +895,21 @@ audit_only
|
|||||||
# taler-wire-auditor.c)
|
# taler-wire-auditor.c)
|
||||||
if [ $DATABASE_AGE -gt 3600 ]
|
if [ $DATABASE_AGE -gt 3600 ]
|
||||||
then
|
then
|
||||||
|
|
||||||
|
# First, we need to run the aggregator so we even
|
||||||
|
# have a wire_out to modify.
|
||||||
|
pre_audit aggregator
|
||||||
|
|
||||||
|
# Modify wire amount, such that it is inconsistent with 'aggregation'
|
||||||
|
# (exchange account is #2, so the logic below should select the outgoing
|
||||||
|
# wire transfer):
|
||||||
|
OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 ORDER BY id LIMIT 1;" | psql $DB -Aqt`
|
||||||
|
OLD_AMOUNT=`echo "SELECT amount FROM app_banktransaction WHERE id='${OLD_ID}';" | psql $DB -Aqt`
|
||||||
|
NEW_AMOUNT="TESTKUDOS:50"
|
||||||
|
echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE id='${OLD_ID}';" | psql -Aqt $DB
|
||||||
|
|
||||||
|
audit_only
|
||||||
|
|
||||||
echo -n "Testing inconsistency detection... "
|
echo -n "Testing inconsistency detection... "
|
||||||
|
|
||||||
AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < test-wire-audit.json`
|
AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < test-wire-audit.json`
|
||||||
@ -928,46 +933,47 @@ then
|
|||||||
exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT"
|
exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT"
|
||||||
fi
|
fi
|
||||||
echo PASS
|
echo PASS
|
||||||
|
|
||||||
|
echo "Second modification: wire nothing"
|
||||||
|
NEW_AMOUNT="TESTKUDOS:0"
|
||||||
|
echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE id='${OLD_ID}';" | psql -Aqt $DB
|
||||||
|
|
||||||
|
audit_only
|
||||||
|
|
||||||
|
echo -n "Testing inconsistency detection... "
|
||||||
|
|
||||||
|
AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < test-wire-audit.json`
|
||||||
|
if test "x$AMOUNT" != "x$OLD_AMOUNT"
|
||||||
|
then
|
||||||
|
exit_fail "Reported justified amount wrong: $AMOUNT"
|
||||||
|
fi
|
||||||
|
AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_wired < test-wire-audit.json`
|
||||||
|
if test "x$AMOUNT" != "x$NEW_AMOUNT"
|
||||||
|
then
|
||||||
|
exit_fail "Reported wired amount wrong: $AMOUNT"
|
||||||
|
fi
|
||||||
|
TOTAL_AMOUNT=`jq -r .total_wire_out_delta_minus < test-wire-audit.json`
|
||||||
|
if test "x$TOTAL_AMOUNT" != "x$OLD_AMOUNT"
|
||||||
|
then
|
||||||
|
exit_fail "Reported total wired amount minus wrong: $TOTAL_AMOUNT (wanted $OLD_AMOUNT)"
|
||||||
|
fi
|
||||||
|
TOTAL_AMOUNT=`jq -r .total_wire_out_delta_plus < test-wire-audit.json`
|
||||||
|
if test "x$TOTAL_AMOUNT" != "xTESTKUDOS:0"
|
||||||
|
then
|
||||||
|
exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT"
|
||||||
|
fi
|
||||||
|
echo PASS
|
||||||
|
|
||||||
|
post_audit
|
||||||
|
|
||||||
|
# cannot easily undo aggregator, hence full reload
|
||||||
|
echo -n "Reloading database ..."
|
||||||
|
full_reload
|
||||||
|
echo "DONE"
|
||||||
else
|
else
|
||||||
echo "Inconsistency detection: SKIP (database too new)"
|
echo "Test skipped (database too new)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "Second modification: wire nothing"
|
|
||||||
NEW_AMOUNT="TESTKUDOS:0"
|
|
||||||
echo "UPDATE app_banktransaction SET amount='${NEW_AMOUNT}' WHERE id='${OLD_ID}';" | psql -Aqt $DB
|
|
||||||
|
|
||||||
audit_only
|
|
||||||
|
|
||||||
echo -n "Testing inconsistency detection... "
|
|
||||||
|
|
||||||
AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_justified < test-wire-audit.json`
|
|
||||||
if test "x$AMOUNT" != "x$OLD_AMOUNT"
|
|
||||||
then
|
|
||||||
exit_fail "Reported justified amount wrong: $AMOUNT"
|
|
||||||
fi
|
|
||||||
AMOUNT=`jq -r .wire_out_amount_inconsistencies[0].amount_wired < test-wire-audit.json`
|
|
||||||
if test "x$AMOUNT" != "x$NEW_AMOUNT"
|
|
||||||
then
|
|
||||||
exit_fail "Reported wired amount wrong: $AMOUNT"
|
|
||||||
fi
|
|
||||||
TOTAL_AMOUNT=`jq -r .total_wire_out_delta_minus < test-wire-audit.json`
|
|
||||||
if test "x$TOTAL_AMOUNT" != "x$OLD_AMOUNT"
|
|
||||||
then
|
|
||||||
exit_fail "Reported total wired amount minus wrong: $TOTAL_AMOUNT (wanted $OLD_AMOUNT)"
|
|
||||||
fi
|
|
||||||
TOTAL_AMOUNT=`jq -r .total_wire_out_delta_plus < test-wire-audit.json`
|
|
||||||
if test "x$TOTAL_AMOUNT" != "xTESTKUDOS:0"
|
|
||||||
then
|
|
||||||
exit_fail "Reported total wired amount plus wrong: $TOTAL_AMOUNT"
|
|
||||||
fi
|
|
||||||
echo PASS
|
|
||||||
|
|
||||||
post_audit
|
|
||||||
|
|
||||||
|
|
||||||
# Undo
|
|
||||||
echo "UPDATE app_banktransaction SET amount='${OLD_AMOUNT}' WHERE id='${OLD_ID}';" | psql -Aqt $DB
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -977,38 +983,53 @@ echo "UPDATE app_banktransaction SET amount='${OLD_AMOUNT}' WHERE id='${OLD_ID}'
|
|||||||
function test_17() {
|
function test_17() {
|
||||||
echo "===========17: incorrect wire_out timestamp================="
|
echo "===========17: incorrect wire_out timestamp================="
|
||||||
|
|
||||||
# First, we need to run the aggregator so we even
|
# Check wire transfer lag reported (no aggregator!)
|
||||||
# have a wire_out to modify.
|
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||||
pre_audit aggregator
|
# re-generating the test database as we do not
|
||||||
|
# report lag of less than 1h (see GRACE_PERIOD in
|
||||||
# Modify wire amount, such that it is inconsistent with 'aggregation'
|
# taler-wire-auditor.c)
|
||||||
# (exchange account is #2, so the logic below should select the outgoing
|
if [ $DATABASE_AGE -gt 3600 ]
|
||||||
# wire transfer):
|
|
||||||
OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 ORDER BY id LIMIT 1;" | psql $DB -Aqt`
|
|
||||||
OLD_DATE=`echo "SELECT date FROM app_banktransaction WHERE id='${OLD_ID}';" | psql $DB -Aqt`
|
|
||||||
# Note: need - interval '1h' as "NOW()" may otherwise be exactly what is already in the DB
|
|
||||||
# (due to rounding, if this machine is fast...)
|
|
||||||
echo "UPDATE app_banktransaction SET date=NOW()- interval '1 hour' WHERE id='${OLD_ID}';" | psql -Aqt $DB
|
|
||||||
|
|
||||||
audit_only
|
|
||||||
post_audit
|
|
||||||
|
|
||||||
echo -n "Testing inconsistency detection... "
|
|
||||||
TABLE=`jq -r .row_minor_inconsistencies[0].table < test-wire-audit.json`
|
|
||||||
if test "x$TABLE" != "xwire_out"
|
|
||||||
then
|
then
|
||||||
exit_fail "Reported table wrong: $TABLE"
|
|
||||||
fi
|
|
||||||
DIAG=`jq -r .row_minor_inconsistencies[0].diagnostic < test-wire-audit.json`
|
|
||||||
DIAG=`echo "$DIAG" | awk '{print $1 " " $2 " " $3}'`
|
|
||||||
if test "x$DIAG" != "xexecution date missmatch"
|
|
||||||
then
|
|
||||||
exit_fail "Reported diagnostic wrong: $DIAG"
|
|
||||||
fi
|
|
||||||
echo PASS
|
|
||||||
|
|
||||||
# Undo
|
# First, we need to run the aggregator so we even
|
||||||
echo "UPDATE app_banktransaction SET date='${OLD_DATE}' WHERE id='${OLD_ID}';" | psql -Aqt $DB
|
# have a wire_out to modify.
|
||||||
|
pre_audit aggregator
|
||||||
|
|
||||||
|
# Modify wire amount, such that it is inconsistent with 'aggregation'
|
||||||
|
# (exchange account is #2, so the logic below should select the outgoing
|
||||||
|
# wire transfer):
|
||||||
|
OLD_ID=`echo "SELECT id FROM app_banktransaction WHERE debit_account_id=2 ORDER BY id LIMIT 1;" | psql $DB -Aqt`
|
||||||
|
OLD_DATE=`echo "SELECT date FROM app_banktransaction WHERE id='${OLD_ID}';" | psql $DB -Aqt`
|
||||||
|
# Note: need - interval '1h' as "NOW()" may otherwise be exactly what is already in the DB
|
||||||
|
# (due to rounding, if this machine is fast...)
|
||||||
|
echo "UPDATE app_banktransaction SET date=NOW()- interval '1 hour' WHERE id='${OLD_ID}';" | psql -Aqt $DB
|
||||||
|
|
||||||
|
audit_only
|
||||||
|
post_audit
|
||||||
|
|
||||||
|
echo -n "Testing inconsistency detection... "
|
||||||
|
TABLE=`jq -r .row_minor_inconsistencies[0].table < test-wire-audit.json`
|
||||||
|
if test "x$TABLE" != "xwire_out"
|
||||||
|
then
|
||||||
|
exit_fail "Reported table wrong: $TABLE"
|
||||||
|
fi
|
||||||
|
DIAG=`jq -r .row_minor_inconsistencies[0].diagnostic < test-wire-audit.json`
|
||||||
|
DIAG=`echo "$DIAG" | awk '{print $1 " " $2 " " $3}'`
|
||||||
|
if test "x$DIAG" != "xexecution date missmatch"
|
||||||
|
then
|
||||||
|
exit_fail "Reported diagnostic wrong: $DIAG"
|
||||||
|
fi
|
||||||
|
echo PASS
|
||||||
|
|
||||||
|
# cannot easily undo aggregator, hence full reload
|
||||||
|
echo -n "Reloading database ..."
|
||||||
|
full_reload
|
||||||
|
echo "DONE"
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Test skipped (database too new)"
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1069,44 +1090,57 @@ echo "DONE"
|
|||||||
function test_19() {
|
function test_19() {
|
||||||
echo "===========19: outgoing wire subject malformed================="
|
echo "===========19: outgoing wire subject malformed================="
|
||||||
|
|
||||||
# Need to first run the aggregator so the outgoing transfer exists
|
# Check wire transfer lag reported (no aggregator!)
|
||||||
pre_audit aggregator
|
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||||
|
# re-generating the test database as we do not
|
||||||
# Generate mal-formed wire transfer subject
|
# report lag of less than 1h (see GRACE_PERIOD in
|
||||||
SUBJECT=YDVD2XBQT62553Z2TX8MM
|
# taler-wire-auditor.c)
|
||||||
# Account #2 = exchange, pick outgoing transfer
|
if [ $DATABASE_AGE -gt 3600 ]
|
||||||
OLD_SUBJECT=`echo "SELECT subject FROM app_banktransaction WHERE debit_account_id=2;" | psql $DB -Aqt`
|
|
||||||
echo "UPDATE app_banktransaction SET subject='${SUBJECT}' WHERE debit_account_id=2;" | psql -Aqt $DB
|
|
||||||
|
|
||||||
audit_only
|
|
||||||
post_audit
|
|
||||||
|
|
||||||
|
|
||||||
echo -n "Testing wire transfer subject malformed detection... "
|
|
||||||
|
|
||||||
DIAGNOSTIC=`jq -r .wire_format_inconsistencies[0].diagnostic < test-wire-audit.json`
|
|
||||||
WANT="malformed subject \`${SUBJECT}'"
|
|
||||||
if test "x$DIAGNOSTIC" != "x$WANT"
|
|
||||||
then
|
then
|
||||||
exit_fail "Reported diagnostic: $DIAGNOSTIC, wanted $WANT"
|
|
||||||
fi
|
|
||||||
jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > /dev/null || exit_fail "Falsly claimed wire transfer not detected"
|
|
||||||
|
|
||||||
DELTA=`jq -r .total_wire_out_delta_minus < test-wire-audit.json`
|
# Need to first run the aggregator so the outgoing transfer exists
|
||||||
if test $DELTA == "TESTKUDOS:0"
|
pre_audit aggregator
|
||||||
then
|
|
||||||
exit_fail "Expected total wire delta minus wrong, got $DELTA"
|
|
||||||
fi
|
|
||||||
DELTA=`jq -r .total_wire_format_amount < test-wire-audit.json`
|
|
||||||
if test $DELTA == "TESTKUDOS:0"
|
|
||||||
then
|
|
||||||
exit_fail "Expected total format amount wrong, got $DELTA"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "PASS"
|
# Generate mal-formed wire transfer subject
|
||||||
|
SUBJECT=YDVD2XBQT62553Z2TX8MM
|
||||||
|
# Account #2 = exchange, pick outgoing transfer
|
||||||
|
OLD_SUBJECT=`echo "SELECT subject FROM app_banktransaction WHERE debit_account_id=2;" | psql $DB -Aqt`
|
||||||
|
echo "UPDATE app_banktransaction SET subject='${SUBJECT}' WHERE debit_account_id=2;" | psql -Aqt $DB
|
||||||
|
|
||||||
# Undo
|
audit_only
|
||||||
echo "UPDATE app_banktransaction SET subject='${OLD_SUBJECT}' WHERE debit_account_id=2;" | psql -Aqt $DB
|
post_audit
|
||||||
|
|
||||||
|
|
||||||
|
echo -n "Testing wire transfer subject malformed detection... "
|
||||||
|
|
||||||
|
DIAGNOSTIC=`jq -r .wire_format_inconsistencies[0].diagnostic < test-wire-audit.json`
|
||||||
|
WANT="malformed subject \`${SUBJECT}'"
|
||||||
|
if test "x$DIAGNOSTIC" != "x$WANT"
|
||||||
|
then
|
||||||
|
exit_fail "Reported diagnostic: $DIAGNOSTIC, wanted $WANT"
|
||||||
|
fi
|
||||||
|
jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > /dev/null || exit_fail "Falsly claimed wire transfer not detected"
|
||||||
|
|
||||||
|
DELTA=`jq -r .total_wire_out_delta_minus < test-wire-audit.json`
|
||||||
|
if test $DELTA == "TESTKUDOS:0"
|
||||||
|
then
|
||||||
|
exit_fail "Expected total wire delta minus wrong, got $DELTA"
|
||||||
|
fi
|
||||||
|
DELTA=`jq -r .total_wire_format_amount < test-wire-audit.json`
|
||||||
|
if test $DELTA == "TESTKUDOS:0"
|
||||||
|
then
|
||||||
|
exit_fail "Expected total format amount wrong, got $DELTA"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "PASS"
|
||||||
|
|
||||||
|
# cannot easily undo aggregator, hence full reload
|
||||||
|
echo -n "Reloading database ..."
|
||||||
|
full_reload
|
||||||
|
echo "DONE"
|
||||||
|
else
|
||||||
|
echo "Test skipped (database too new)"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1114,34 +1148,46 @@ echo "UPDATE app_banktransaction SET subject='${OLD_SUBJECT}' WHERE debit_accoun
|
|||||||
function test_20() {
|
function test_20() {
|
||||||
echo "===========20: reserve closure done properly ================="
|
echo "===========20: reserve closure done properly ================="
|
||||||
|
|
||||||
OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
|
# NOTE: This test is EXPECTED to fail for ~1h after
|
||||||
OLD_VAL=`echo "SELECT credit_val FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
|
# re-generating the test database as we do not
|
||||||
RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
|
# report lag of less than 1h (see GRACE_PERIOD in
|
||||||
OLD_EXP=`echo "SELECT expiration_date FROM reserves WHERE reserve_pub='${RES_PUB}';" | psql $DB -Aqt`
|
# taler-wire-auditor.c)
|
||||||
VAL_DELTA=1
|
if [ $DATABASE_AGE -gt 3600 ]
|
||||||
NEW_TIME=`expr $OLD_TIME - 3024000000000` # 5 weeks
|
then
|
||||||
NEW_EXP=`expr $OLD_EXP - 3024000000000` # 5 weeks
|
|
||||||
NEW_CREDIT=`expr $OLD_VAL + $VAL_DELTA`
|
|
||||||
echo "UPDATE reserves_in SET execution_date='${NEW_TIME}',credit_val=${NEW_CREDIT} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB
|
|
||||||
echo "UPDATE reserves SET current_balance_val=${VAL_DELTA}+current_balance_val,expiration_date='${NEW_EXP}' WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
|
|
||||||
|
|
||||||
# Need to run with the aggregator so the reserve closure happens
|
OLD_TIME=`echo "SELECT execution_date FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
|
||||||
run_audit aggregator
|
OLD_VAL=`echo "SELECT credit_val FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
|
||||||
|
RES_PUB=`echo "SELECT reserve_pub FROM reserves_in WHERE reserve_in_serial_id=1;" | psql $DB -Aqt`
|
||||||
|
OLD_EXP=`echo "SELECT expiration_date FROM reserves WHERE reserve_pub='${RES_PUB}';" | psql $DB -Aqt`
|
||||||
|
VAL_DELTA=1
|
||||||
|
NEW_TIME=`expr $OLD_TIME - 3024000000000` # 5 weeks
|
||||||
|
NEW_EXP=`expr $OLD_EXP - 3024000000000` # 5 weeks
|
||||||
|
NEW_CREDIT=`expr $OLD_VAL + $VAL_DELTA`
|
||||||
|
echo "UPDATE reserves_in SET execution_date='${NEW_TIME}',credit_val=${NEW_CREDIT} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB
|
||||||
|
echo "UPDATE reserves SET current_balance_val=${VAL_DELTA}+current_balance_val,expiration_date='${NEW_EXP}' WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
|
||||||
|
|
||||||
echo -n "Testing reserve closure was done correctly... "
|
# Need to run with the aggregator so the reserve closure happens
|
||||||
|
run_audit aggregator
|
||||||
|
|
||||||
jq -e .reserve_not_closed_inconsistencies[0] < test-audit.json > /dev/null && exit_fail "Unexpected reserve not closed inconsistency detected"
|
echo -n "Testing reserve closure was done correctly... "
|
||||||
|
|
||||||
echo "PASS"
|
jq -e .reserve_not_closed_inconsistencies[0] < test-audit.json > /dev/null && exit_fail "Unexpected reserve not closed inconsistency detected"
|
||||||
|
|
||||||
echo -n "Testing no bogus transfers detected... "
|
echo "PASS"
|
||||||
jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > /dev/null && exit_fail "Unexpected wire out inconsistency detected in run with reserve closure"
|
|
||||||
|
|
||||||
echo "PASS"
|
echo -n "Testing no bogus transfers detected... "
|
||||||
|
jq -e .wire_out_amount_inconsistencies[0] < test-wire-audit.json > /dev/null && exit_fail "Unexpected wire out inconsistency detected in run with reserve closure"
|
||||||
|
|
||||||
# Undo
|
echo "PASS"
|
||||||
echo "UPDATE reserves_in SET execution_date='${OLD_TIME}',credit_val=${OLD_VAL} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB
|
|
||||||
echo "UPDATE reserves SET expiration_date='${OLD_EXP}',current_balance_val=current_balance_val-${VAL_DELTA} WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
|
# cannot easily undo aggregator, hence full reload
|
||||||
|
echo -n "Reloading database ..."
|
||||||
|
full_reload
|
||||||
|
echo "DONE"
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Test skipped (database too new)"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1225,9 +1271,10 @@ then
|
|||||||
|
|
||||||
echo "PASS"
|
echo "PASS"
|
||||||
|
|
||||||
# Undo
|
# cannot easily undo aggregator, hence full reload
|
||||||
echo "UPDATE reserves_in SET execution_date='${OLD_TIME}',credit_val=${OLD_VAL} WHERE reserve_in_serial_id=1;" | psql -Aqt $DB
|
echo -n "Reloading database ..."
|
||||||
echo "UPDATE reserves SET expiration_date='${OLD_EXP}',current_balance_val=current_balance_val-${VAL_DELTA} WHERE reserve_pub='${RES_PUB}';" | psql -Aqt $DB
|
full_reload
|
||||||
|
echo "DONE"
|
||||||
else
|
else
|
||||||
echo "Test skipped (database too new)"
|
echo "Test skipped (database too new)"
|
||||||
fi
|
fi
|
||||||
@ -1249,6 +1296,8 @@ fi
|
|||||||
# *************** Main test loop starts here **************
|
# *************** Main test loop starts here **************
|
||||||
|
|
||||||
|
|
||||||
|
# Run all the tests against the database given in $1.
|
||||||
|
# Sets $fail to 0 on success, non-zero on failure.
|
||||||
check_with_database()
|
check_with_database()
|
||||||
{
|
{
|
||||||
BASEDB=$1
|
BASEDB=$1
|
||||||
@ -1283,20 +1332,13 @@ check_with_database()
|
|||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
echo "Cleanup (disabled)"
|
||||||
|
# dropdb $DB
|
||||||
|
# rm -r $WIRE_FEE_DIR
|
||||||
|
# rm -f test-audit.log test-wire-audit.log
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
echo "Cleanup (disabled)"
|
|
||||||
# dropdb $DB
|
|
||||||
# rm -r $WIRE_FEE_DIR
|
|
||||||
# rm -f test-audit.log test-wire-audit.log
|
|
||||||
|
|
||||||
# if test -n "${MYDIR:-}"
|
|
||||||
# then
|
|
||||||
# rm -rf $MYDIR
|
|
||||||
# fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# *************** Main logic starts here **************
|
# *************** Main logic starts here **************
|
||||||
|
|
||||||
@ -1320,21 +1362,26 @@ if test -n "${1:-}"
|
|||||||
then
|
then
|
||||||
echo "Custom run, will only run on existing DB."
|
echo "Custom run, will only run on existing DB."
|
||||||
else
|
else
|
||||||
echo "Testing for taler-wallet-cli"
|
echo -n "Testing for taler-wallet-cli"
|
||||||
if taler-wallet-cli -h >/dev/null </dev/null 2>/dev/null
|
if taler-wallet-cli -h >/dev/null </dev/null 2>/dev/null
|
||||||
then
|
then
|
||||||
MYDIR=`mktemp -d /tmp/taler-auditor-basedbXXXXXX`
|
MYDIR=`mktemp -d /tmp/taler-auditor-basedbXXXXXX`
|
||||||
echo " FOUND. Generating fresh database at $MYDIR"
|
echo " FOUND. Generating fresh database at $MYDIR"
|
||||||
if ./generate-auditor-basedb.sh $MYDIR/basedb
|
if ./generate-auditor-basedb.sh $MYDIR/basedb
|
||||||
then
|
then
|
||||||
check_with_database $MYDIR
|
check_with_database $MYDIR/basedb
|
||||||
if test x$fail != x0
|
if test x$fail != x0
|
||||||
then
|
then
|
||||||
exit $fail
|
exit $fail
|
||||||
|
else
|
||||||
|
echo "Cleaning up $MYDIR..."
|
||||||
|
rm -rf $MYDIR || echo "Removing $MYDIR failed"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Generation failed, running only on existing DB"
|
echo "Generation failed, running only on existing DB"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo " NOT FOUND, running only on existing DB"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user